How to force a new autonumber on acNewRec?

Tekime

Registered User.
Local time
Today, 18:46
Joined
Jun 26, 2003
Messages
72
Hi all,

I'm using a popup form to enter new data into a table (tbl_Applications). I am passing an ID (apartmentId) via OpenArgs which needs to be stored in a non-primary field in tbl_Applications.

I'm using the acNewRec parameter to go automatically to a new record. The problem is that I need to programatically force the new autonumber to be generated so I can set the apartmentId field (bound to a field in tbl_Applications) based on the value received from openargs. Since the autonumber is only generated once the form is dirty, is there a way to force the new record to be created in VBA in the onOpen event of the form?

I have tried setting the apartmentId on open to no avail.

Me.apartmentId = apartmentId ' Doesn't work, no autonumber created

I've also tried docmd.save and a few other things to no avail.

I'm probably missing something simple being that I'm quite sleep deprived as the project I'm working on is consuming my life. :)

Many thanks for any input.
 
Tekime,
I do this, from the Current Event of my Form.


Private Sub Form_Current()

If Me.NewRecord Then
apartementID = ....



hope this helps, Good Luck!
 
Good point Pat, I believe i misunderstood the objective.
 

Users who are viewing this thread

Back
Top Bottom