Help with Code Please!

hinser13

Registered User.
Local time
Today, 03:27
Joined
Aug 8, 2010
Messages
75
I have two sections of code

1: To create a new account
2: To open a form

I am new to code so as you will see a little stuck. How do I stich the following code together to make it one event, as apposed to two seperate, Sorry for my ignorance!

Private Sub Command57_Click()
On Error GoTo Err_Command57_Click
DoCmd.GoToRecord , , acNewRec
Exit_Command57_Click:
Exit Sub
Err_Command57_Click:
MsgBox Err.Description
Resume Exit_Command57_Click
End Sub


Private Sub Command103_Click()
On Error GoTo Err_Command103_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmAccountNumberManagement"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command103_Click:
Exit Sub
Err_Command103_Click:
MsgBox Err.Description
Resume Exit_Command103_Click
End Sub
 
Try;
Code:
Private Sub Command103_Click()
On Error GoTo Err_Command103_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmAccountNumberManagement"
DoCmd.OpenForm stDocName, , , stLinkCriteria
[B][COLOR="Red"]DoCmd.GoToRecord acDataForm, stDocName, acNewRec[/COLOR][/B]
Exit_Command103_Click:
Exit Sub
Err_Command103_Click:
MsgBox Err.Description
Resume Exit_Command103_Click
End Sub

You could also simply us;
Code:
Private Sub Command103_Click()
On Error GoTo Err_Command103_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmAccountNumberManagement"
DoCmd.OpenForm stDocName, , , stLinkCriteria[B][COLOR="Red"], acFormAdd[/COLOR][/B]
Exit_Command103_Click:
Exit Sub
Err_Command103_Click:
MsgBox Err.Description
Resume Exit_Command103_Click
End Sub
 
Thank you for your help John, much appreciated
 

Users who are viewing this thread

Back
Top Bottom