Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Parent-child form question
Message
 
To
10/03/2000 10:28:26
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00344200
Message ID:
00344229
Views:
18
>Hi all,
>
> I am working on a parent child form which is used to make purchase orders. I use 2 views for this form(one I called purchase_order, the 2nd is purchase_item) They are related to each other by a field I called po_no(automatic no. from the SQL Server)
> On this form I have to add the parent part first and then the child part. The po_no(which is the connection between 2 views) does not show up until I have this code(on the buttonset)
>*******
>if (thisform.PO_NO_ID1.value = 0) and
> (thisform.buttonset1.cmdadd.caption = "\> =requery()
> thisform.refresh()
>endif
> dodefault()
>*******
> I do "requery" to get the po_no which is needed for the child part. But my problem here is after I requery, the first record(on the parent part) always comes up on the screen. I just want to stay at the record I just added(from parent part), then I can add more child records.
> Any suggestions would be appreciated.
> Thanks in advance.

Hi Hobby,

Do you mean you have more than 1 parent record in the view? In this case after requery() the record pointer always go to the first record in the view. You should position the record pointer on newly added record yourself. You can do LOCATE FOR some_field_from_view = somevalue_from_added_record after your REQUERY()
Another solution may be if you do not use the automatic key field increment from SQL Server, but update the key field yourself from the view. For the key generation you may have the stored procedure on SQL Server. When you want to add the record, you obtain the key from the stored procedure, then do your Tableupdate(), updating the key field with the new key value. In this case you don't need the REQUERY() and the record pointer satys on added record.

Nick
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform