Forcing a disk write to save a record

D

Dave

I have a form that I create a new record on. The record has an primary key
that is defined with an IDENTITY property (this is an adp project).

I want to insert this new record into another table while I am still on the
original form. I have code to do this but I need the PK value which has not
been saved to disk yet.

How can I force a save so the IDENTITY property value will be available?

I have tried...

Me.Refresh

Me.Requery

....and...

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70

but none will force the save. The text box with the ID continues to
display "(AutoNumber)" until I move off the record.

Is this something specific to ADP and SQL Server?

Any ideas?
 
G

Graham Mandeno

Hi Dave

The new AutoNumber value will not be generated until the form is dirtied for
the first time. If you want to save the record with the ID value (and other
field default values) and nothing else, then you can trick it into thinking
the record has been changed and *then* save the record:

Me![some control] = Me![some control]
DoCmd.RunCommand acCmdSaveRecord
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top