Home > Archive > FoxPro Help and Support > October 2005 > Re: Using table with CursorAdapter - how can I get the ID of latest









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Using table with CursorAdapter - how can I get the ID of latest
borisb

2005-10-27, 8:34 am

bzamfir@gmail.com wrote:
> Hi,
>
> I have an application and I use CursorAdapters for all tables.
> I have the following problem: I have to create a new record in a table,
>
> find it't id (integer auto-increment) and pass it to another module
>
> Specifically, user create a master record, then (before they save and
> exit) they can also create one or more child records in several other
> tables. So when they open the forms for the child tables, I havre to
> know the ID for the master record, and pass it to the form handling the
>
> child table, to set it as foreign key.
>
> The problem is I have troubles finding the ID. I use a very odd method
> right now, which works, but I'm not happy with it.
>
> Can anyone give me so thoughts on how to get this done in an elegant
> way?
>
> Thanks,
> Bogdan
>
>


Something like that:
Field1 is AutoIncrement field and you put it into the selectcmd property
of the CA.

INSERT INTO MyCA (Field2, Field3...FieldN) VALUES (val1,val2...valN)
IF TableUpdate(1, .t., "MyCA")
MyCursorAdapterObjec
t.CursorRefresh()
*** Find the record you just added (use see, locate, goto etc.)
m.lnNewId = Field1
ENDIF

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com