button coding

hayden

Registered User.
Local time
Today, 03:28
Joined
Mar 16, 2010
Messages
49
i have a booking form and i have this button so that if a the customer doesnt have an account then when i click it opens up the customer form so add them, however my problem is that i cannot get it to open on a new record it always opens on a completed one ive looked through forum tried various things in my code to no success any help be grateful

this is the current code for the button

Private Sub create_cust_account_Click()
On Error GoTo Err_create_cust_account_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "ABC BOUNCERS NEW CUSTOMER"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_create_cust_account_Click:
Exit Sub
Err_create_cust_account_Click:
MsgBox Err.Description
Resume Exit_create_cust_account_Click

End Sub



cheers hayden
 
Did you look in the help files for the OpenForm options? Your code looks like it was created with the wizard.

DoCmd.OpenForm "ABC BOUNCERS NEW CUSTOMER", acNormal, "", "", acAdd, acNormal

That will open the form to a new record.
 
thank you and yes it was created with a wizard
 
I suggest you select and highlight parts in your code like OpenForm and press the F1 key to open the help file and see what Microsoft has to say about the command. You will learn a lot about VBA by using the built-in help files.
 
I entered the code and it works however, it doesnt allow me to view the other records once entered the new details is there away of doing that
 
Is the user not done with the form once they have created the new record? I would close the form once they have saved the new record and go back to the booking form. Or you can create a custom save button and reopen the customer form in the edit mode instead of the add new record mode [which is why you cannot see old records].

Look in the help files for the OpenForm method to see which AcFormOpenDataMode option allows you to open the form in the normal view.
 

Users who are viewing this thread

Back
Top Bottom