MS-Access open form on new record

I have a form with the RecordSet set to table with an autoincrement field, ID, as the primary index.  

I added an acCmdRecordsGoToNew command to the Form.open event.  The new record for this table doesn't seem to get created until I modify one of the fields on the table which is when then the ID field get populated.  Is there anyway to force the creation of the new record right from the get go so the ID is populated before the user enters anything?
jsenerisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TextReportCommented:
If you set a value of a bound control in code (Me.ControlName = "Value") after your acCmdRecordsGoToNew command it will dirty the record and then you will receive the ID value. I would not normally work this way though.
Cheers, Andrew
0
peter57rCommented:
Andrew said...
'I would not normally work this way though.'

Nor me.
I can't imagine why you would want to force a record to be created until the user is ready to do so.  What if they clicked the button by mistake?
0
jsenerisAuthor Commented:
I'm using the autoincrement field as an 'Invoice ID', which is a unique number.

I want to set the record on form entry because I hate seeing "(autonumber)" in the Invoice ID field.  I would never allow that to show on a form if I was programming in a different environment.  I thought about using a seperate fields for Invoice Id and one for the primary ID, but then I have to worry about duplicating Invoice Id.

Also the form populates values in a child table to the Invoice table, and then I have disable that ability until the user enter info on the parent table, which just seems ugly.

Besides how hard is it to delete and empty record on form close?  If there ends up being a slew of people hitting the "Add record" button without meaning to, enough so that it causes a problem; then I've gotten a bigger problem...really stupid users. >:)




0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

TextReportCommented:
I would not show the AutoNumber Field either, I would have a separate control of =txtID this ont show the AutoNumber option but will show the InvoiceNo when you save the record.
Cheers, Andrew
0
jsenerisAuthor Commented:
Ok.  You guys win.  I won't pre-populate the Invoice ID.  One last question, when you say you would have a seperate control that won't show the AutoNumber option; is the field bound to the AutoNumber field and just hidden until the record save, or are you suggesting a seperate field altogether?
0
TextReportCommented:
No it's control Source points to the AutoNumber control as in my example above txtID is the name of the bound control with the AutoNumber in it, hide it and set the controlsource of the new textbox to =txtID

Cheers, Andrew
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.