Forcing Autonumber Field - Not Working...

RichO

Registered Yoozer
Local time
Today, 05:34
Joined
Jan 14, 2004
Messages
1,036
On my form, there is a button that will auto-populate the subform.

If this button is clicked before the autonumber ID is established the code crashes. I have tried saving the record using...

DoCmd.RunCommand acCmdSaveRecord

...but this does not save the record. After executing this command I can even go into the table where this record is supposed to have been saved and it is not there.

There must be something I'm missing here. Any ideas?

Thanks
 
Did you populate with data all required fields?
 
That's the problem. Until you enter data (make the form dirty) the ID number does not exist. By searching here I found similar questions about forcing the autonumber and the answer was to execute a save command.

But that is not working in my case.
 
Is your form is based on query? If so try adding data on query to look whats wrong.

If you can post database. I can check whats wrong
 
The form uses a table as its record source.

I wouldn't be able to post the DB. It's quite large and has a SQL server back end.
 
The only reason I want to do this is that if a user clicks on the auto-fill button (that fills the subform with commonly selected data) and nothing has been typed into the main form yet, an error occurs.

Currently I am checking for the existence of the ID number before proceeding with the code, which works fine, but I was just wondering if that could be avoided.
 

Users who are viewing this thread

Back
Top Bottom