Automatically populate Primary key values to grid using Header Detail Form

jefrey

jefrey

Active Member
Hi Listers!

I have a Header Detail form which adds/updates a One-to-many records. The grid is set to 'No Adds on Update Grid' = true, because rows are added tru codes. Rows are inserted using the 'Insert Grid Buffer Row' system function.

The table in the header section of the form has one Primary key 'ID'. And the table attached to the grid has two primary keys == 'ID','LineID'.

Is it possible to automatically populate primary key values to the grid (or is it a feature of a header detail form) if new row entry is created?

Can the values to the grid be automatically set to ID = 001 if the ID of the header is equal to 001?
If it is NOT possible, can you suggest what to do to achieve my goal. I've tried to set the grid's ID at 'Grid Record is Fetched' but it doesn't solve my problem. I also tried setting GC ID = 001 right after the 'Insert Grid Buffer Row' but still not helpful.

Any bright ideas?
 
Hi Jefrey,

First of all:
A.) I'm not experinced still on 8.12 (on your release)
B.) I worked only on vanilla Header/Detail forms, I have never used it in my custom applications, none the less I had created more hubdred applications with much more Forms - I used Fix Inspect and Headerless/detail forms tied in the same transaction boundary.

What about:
#1. Populate GB ID before Insert Grid Buffer Row?
#2. Populate BC ID in the Before Add and/or Before Update grid events?

Please, let us know, if one of them works on your scenario. Thanks.

Regards,

Zoltán
 
Zoltan,

As usual, you are right!
I did update the GB before Insert Grid Buffer Row and it worked. My other question is Header/Detail Form is not designed to automatically assign ID's to the grid based on the ID in the Header? If yes, so it is only designed to update two tables at the same time.

Thanks Zoltan.
 
Jefrey,

I'm not sure of your question.

Are you asking if the form updates only 2 tables - as compared to 3? or if the form only updates 2 tables and the administrative (adding the keys) stuff is up to me?

I'm guessing that it is the second one. It is not unreasonable that the header detail relationship is not based upon the primary key of the header and instead is linked via a secondary key.

One example might be:
1) Batch Header key: UKID
2) Batch Detail key: UKID LNID Header key: DOCO, DCTO
3) Detail key: DOCO, DCTO, LINS

Sorry can't think of any scenarios to explain this relationship, but I have seen similar things. In any case, if the Header/Detail screen were to autopopulate keys then a Header/Detail setup on the 2nd and 3rd tables would not be allowed.

By the way, you can populate the keys via a couple of options.
Grid Record Entered - not a great place because if user clicks into an empty grid - he now has a record whether he wants it or not.
Grid Record Exited and Changed - Inline - One of the better places, so you test for a value in one of the other fields. Beware that putting a space in a string (it's already there) will make the engine think the record has changed.
Usually, there is a field that is required other than the keys, so on Control Is Exited & Changed - Inline is a good place to populate the keys, then there is only a test on one field, and the keys populate while the user is still in the row.

Ben again,
 
Hi jefrey,

One Question?

Are you populating the GB ID field with your FC ID/ Header ID value before doing "Insert Grid Buffer Row"?
 
[ QUOTE ]
Hi jefrey,

One Question?

Are you populating the GB ID field with your FC ID/ Header ID value before doing "Insert Grid Buffer Row"?

[/ QUOTE ]

Yes. But if possible, i dont want to manually populate the ID column in the grid.
 
Back
Top