Link to home
Start Free TrialLog in
Avatar of misha051797
misha051797

asked on

Adding to rdoResultset

I have created a rdoResultset using VB 4.0 and filled the Resultset using select statement from SQL 6.0 server database.

When I want to add new record to a table I use the addnew method:

oRec.AddNew
oRec!IsBook = 1
oRec!Code = DoQuotes(ItemType)
oRec!Description = "Not set yet"
oRec.Update

mnItemTypeID = oRec!PKId ' this is the key
oRec.Close
Set oRec = Nothing

As you can see I need to retrieve the just entered and automatically assigned PKId. I expected the current record pointer to point to the newly created record, but it points to the first record in the recordset instead. Does the rdo work say way as DAO? What is my solution? I cant issue oRec.movelast due to multi-user limitation.
Please share your experience with RDO.
Thank you


Avatar of mark2150
mark2150

The .AddNew should init the key. Try grabbing it prior to the .Update. .Update commits the record in memory to disk. Any Automatic fields should be created when the .AddNew fires, NOT when the .Update triggers.
Avatar of misha051797

ASKER

Thank you,
but where is my record pointer is pointing to?
ASKER CERTIFIED SOLUTION
Avatar of mark2150
mark2150

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial