?
Solved

MS-Access open form on new record

Posted on 2008-02-04
6
Medium Priority
?
7,004 Views
Last Modified: 2013-11-28
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?
0
Comment
Question by:jseneris
  • 3
  • 2
6 Comments
 
LVL 28

Expert Comment

by:TextReport
ID: 20821305
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
 
LVL 77

Assisted Solution

by:peter57r
peter57r earned 80 total points
ID: 20821999
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
 

Author Comment

by:jseneris
ID: 20822209
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
LVL 28

Expert Comment

by:TextReport
ID: 20822239
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
 

Author Comment

by:jseneris
ID: 20822432
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
 
LVL 28

Accepted Solution

by:
TextReport earned 120 total points
ID: 20822519
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

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
A quick solution showing how to control and open a POS Cash Register Drawer using VBA with MS Access.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question