Link to home
Start Free TrialLog in
Avatar of jseneris
jseneris

asked on

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?
Avatar of TextReport
TextReport
Flag of United Kingdom of Great Britain and Northern Ireland image

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
SOLUTION
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jseneris
jseneris

ASKER

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. >:)




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
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?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial