Don't worry about the autonumber field, just keep adding your records. When you go back and review, you will find the autonumber field properly filled in.
Main Topics
Browse All TopicsHi Guys,
Hoping you can help me out. I have a form to enter a new record in a table. The primary key of the table is a long integer autonumber field. I set the form to DataEntry "yes" to it opens blank. Which means it does not populate that autonumber field with the next value. I added a command button at the bottom to add the record. However, whenever clicked, I get an error because obviously the autonumber field is still null and is required and not allowed to be null. I have tried many of the solutions I have found here, but no dice. Any idea how I can put the next increment of that autonumber field in there before it attempts to add the new record to the DB? Thanks.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Thanks for the quick input all. I guess I will try to explain a little more. The problem is that when I click to add, it tells me that field is null which isn't allowed. When I set the form to be DataEntry, it no longer auto populates that key autonumber field with the next value. It is left blank. Which is why I am trying to generate it. I did try the DMax in the beforeInsert but it kicked back a type mismatch.
Me.txtID.Value = DMax("id", "users") + 1
txtID is the form textbox, id is the db field and users is the database table
Hi
Please upload the db if you can....Autonumber will always be populate automatically and you cannot change the value. Try to do add some data in data entry and close the form, go to table and see if primary key number was generated if you cannot add the record in the form go to the table and add the data and try to go to next row you should get the same message.
As mentioned above check table design and check all fields which have required property set to yes also check validation rule (is not null). Also if you haven't build the form check if any of the controls on the form are not set up to required = yes.
Uploading portion of the db should be the quickiest way to help you.
Regards
Emil
Business Accounts
Answer for Membership
by: DatabaseMXPosted on 2009-10-30 at 12:02:04ID: 25705894
You really can't do that. The AN is not created until the 'new record' becomes 'Dirty' ... which happens as soon as any 'bound' control becomes edited in some way (character in a text box, etc.).
Further, you cannot *reliably* get the AN until the record has been saved.
mx