Possible to open form in Add mode using VBA??

snagrat

Registered User.
Local time
Today, 21:33
Joined
Apr 2, 2002
Messages
61
When one of my forms opens off another form it opens showing the first field.

I want to make it so it opens in add mode so I can add data to the table

Is this possible and if so what code do I have to use??
 
On the form load event put the code:

DoCmd.GotoRecord, , acNew
 
It keeps coming up with an error. I have other code in the form load section. Below is what I have:

Private Sub Form_Load()

DoCmd.GoToRecord , , acNew

txtQuantity = ""
cboCustomerID = [Forms]![frmNewInvoice]![cboCustomerID]
cboProductID = ""
cboCustomerID.Visible = False

End Sub

The DoCmd.GoToRecord , , acNew creates the error.

What am I doing wrong?
 
You can also open the form in Add mode. That will let you just add a new record.

Instead of

DoCmd.OpenForm "FormName"

Use

DoCmd.OpenForm "FormName", , , , acFormAdd

HTH
 
The form does have a RecordSource, doesn't it?
 

Users who are viewing this thread

Back
Top Bottom