Problem:
I have a form that adds the current date to a date filled when a new record is opened. I need to be able to save the record and get the id (autonumber) of the record to use for something else.
However, when I try to save the record in code no id has been generated yet.
Overview:
So, when the form is opened on a new record, the date field defaults to today.
I then click a button to save this record so I can reference the ID. I've used
Code:
If Me.Dirty Then
Me.Dirty = False
end if
and
Code:
DoCmd.RunCommand acCmdSaveRecord
However, later (in the code of the same button) when I try to reference me.id it is always null.
How can I force access to save this record and generate an ID for it so I can use that ID?