How do I get the newly created key?

electro

Registered User.
Local time
Today, 18:19
Joined
Sep 8, 2006
Messages
27
I have tables which I add a new post to. But I want to find its key.
Code:
DoCmd.GoToRecord , , acNewRec
'Lot of data fills out the different textboxes
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
    DoCmd.Requery
When I first save the data and the requery the you should expect the ID field on form to have the new unique number but it doesnt. Can you get the current unique ID on some other way?
 
the ID field should automatically increase as soon as you start to enter data. are you sure the form is bound to a table or query?
to save i usually use:
Code:
docmd.runcommand accmdsaverecord
then you should be able to reference the ID by:
Code:
me.IDfieldcontrol
does this change anything?
 
the ID field should automatically increase as soon as you start to enter data. are you sure the form is bound to a table or query?
to save i usually use:
Code:
docmd.runcommand accmdsaverecord
then you should be able to reference the ID by:
Code:
me.IDfieldcontrol
does this change anything?
Dont know why but replacing
Code:
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
with
Code:
DoCmd.RunCommand acCmdSaveRecord
solved it.

Whats the difference between the two?
Thanks for your help
 

Users who are viewing this thread

Back
Top Bottom