Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add Record Error

Status
Not open for further replies.

Xtremlylost

Technical User
Jul 18, 2002
25
0
0
US
Thanks for opening.
I have a form with several controls set to default values when a new record is generated to help the users enter as little as possible. I believe this is what is causing the problem when a user "accidentally" hits the "Add record" button and then tries to go back to the previous record without entering anything in the first field. This field is a primary key field that the query is related through. It appears that Access is trying to save the record but cannot because there are not related records between the two tables.
What code and what event should I revise so that if no information is entered in the beginning field (through the described process) then it acts normally and eliminates the unchanged record when it moves to any other record? I also have to avoid saving any records that does not have the primary key field filled out...
Any help would be greatly appreciated.

Sometimes the view is perfect right where you are and sometimes falling is the only way to know it.
 
Have you considered waiting until the key field is entered before filling in your default values? You might do this on, for instance, the lost focus event of the key field.
 
Hey Randy700,
This worked finally. I couldn't put it in the first field because it still kicked the error out apparently because canceling the new record by arrowing back on the record selectors kicked the lost focus event and it still wanted to save the record. I ended up putting the default value fill in the second tabbed field which is working well. I am having some assumption that if they tab into the second field they are wanting to generate a record they want to save. Aren't assumptions useful tools!!! Thanks for your input. It is working now with your help.
XL

Sometimes the view is perfect right where you are and sometimes falling is the only way to know it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top