Code for a Form to add new record on open instead of relying on using a cmd button?

Goli

New member
Local time
Today, 18:58
Joined
Jan 21, 2008
Messages
6
Hi there,

Does anybody know how I would set a form to create a new record when it is opened aswell as having a cmd button to add new record.

I have a database used by several people with a differing knowledge of Access DBs. I have noticed that some people are overwriting data by typing over the first record in the db instead of clicking the add new record button.

I was wondering if I could set the form in question to automatically add a new record when it is opened?

Any help would be greatly appreciated!

Thanks,

G
 
You can either set its Data Entry property to yes or use the DataMode argument of OpenForm to set it when you open it (which would allow you to use it either way).
 
insert this as the code as the button that opens the form

Code:
DoCmd.OpenForm "Your Form Name Here", , , acNewRec
Or

Put this in your onload event:

Code:
DoCmd.GoToRecord , , acNewRec
 
insert this as the code as the button that opens the form

Code:
DoCmd.OpenForm "Your Form Name Here", , , acNewRec

That's the WhereCondition argument, not the DataMode argument.
 

Users who are viewing this thread

Back
Top Bottom