Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Parent-child form question
Message
 
 
To
13/03/2000 11:34:15
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00344200
Message ID:
00345042
Views:
29
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.
> **********************
>Hello Nick,
> Let me tell you more about my problem now. For instance, I have 5 records on the parent view(the po_no is automatic no. and increase from 1 to 5). On the "View designer" of the parent view, I have "Order by" by po_no descending. If I am on the record from 2 to 5 to add a new parent record, when I do requery() to get the new po_no(which is 6), everything works just fine(it stays at the newly added record and the users can add child records there), but if I start from record 1 to add a new record, after I clisk "Save", it always goes back to the record 1.
> Because I set "descending" for the po_no, when I first run the form, I always start at the record has biggest po_no. But sometimes the users click on "Bottom" on the buttonset, at that position they add new record and they can make mistake because of my problem(if they don't recognize the situation). Is there any way that I can make the form stay at the newly added record no matter which record I start on?
> I just want to prevent that problem for the negligent users.
> Any susgestion would be appreciated! Thank you in advance.
> Hobby.

In save method

local lnRecno
lnRecno=Recno()

=TableUpdate(...)
if between(lnrecno,1,reccount()) && this record was just editted
go lnRecno
else
go bottom && should go to the last record, which was just added
endif
HTH
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform