S
Sue Wilkes
I have a form with a command button which when clicked returns the users to
the main menu on the switchboard. I have tried to add data validation but
when the button is clicked it gives the error message then saves the record
and returns to the Main Menu. I have posted my code below could anybody
please tell me what I'm doing wrong. I would like them to be placed back on
the form to either complete and save the record as normal or cancel all
changes & then return to Main Menu. The error message for 'designation code'
does not appear in full any pointers on this would be gratefully appreciated.
Many thanks Sue
Private Sub ReturntoMainMenu_Click()
On Error GoTo Err_ReturntoMainMenu_Click
If IsNull(Me.Designation) Then
MsgBox conMESSAGE, vbExclamation, "CANCEL ALL CHANGES OR ENTER
DESIGNATION DETAILS & SAVE RECORD BEFORE EXITING TO MAIN MENU"
Canel = True
Me.Designation.SetFocus
End If
If IsNull(Me.SentTo) Then
MsgBox conMESSAGE, vbExclamation, "ENTER SENT TO DETAILS BEFORE
CONTINUING"
Canel = True
Me.SentTo.SetFocus
End If
If IsNull(Me.CopiedTo) Then
MsgBox conMESSAGE, vbExclamation, "ENTER COPIED TO DETAILS BEFORE
CONTINUING"
Canel = True
Me.CopiedTo.SetFocus
End If
If IsNull(Me.DateSent) Then
MsgBox conMESSAGE, vbExclamation, "ENTER DATE AS DD/MM/YYYY BEFORE
CONTINUING"
Canel = True
Me.DateSent.SetFocus
End If
If IsNull(Me.CompanyNames) Then
MsgBox conMESSAGE, vbExclamation, "ENTER COMPANY NAME DETAILS BEFORE
CONTINUING"
Canel = True
Me.CompanyNames.SetFocus
End If
If IsNull(Me.Subject) Then
MsgBox conMESSAGE, vbExclamation, "ENTER SUBJECT DETAILS BEFORE
CONTINUING"
Canel = True
Me.Subject.SetFocus
End If
If IsNull(Me.Hyperlink1) Then
MsgBox conMESSAGE, vbExclamation, "ENTER HYPERLINK BEFORE CONTINUING"
Canel = True
Me.Hyperlink1.SetFocus
End If
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Switchboard"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_ReturntoMainMenu_Click:
Exit Sub
Err_ReturntoMainMenu_Click:
MsgBox Err.Description
Resume Exit_ReturntoMainMenu_Click
End Sub
the main menu on the switchboard. I have tried to add data validation but
when the button is clicked it gives the error message then saves the record
and returns to the Main Menu. I have posted my code below could anybody
please tell me what I'm doing wrong. I would like them to be placed back on
the form to either complete and save the record as normal or cancel all
changes & then return to Main Menu. The error message for 'designation code'
does not appear in full any pointers on this would be gratefully appreciated.
Many thanks Sue
Private Sub ReturntoMainMenu_Click()
On Error GoTo Err_ReturntoMainMenu_Click
If IsNull(Me.Designation) Then
MsgBox conMESSAGE, vbExclamation, "CANCEL ALL CHANGES OR ENTER
DESIGNATION DETAILS & SAVE RECORD BEFORE EXITING TO MAIN MENU"
Canel = True
Me.Designation.SetFocus
End If
If IsNull(Me.SentTo) Then
MsgBox conMESSAGE, vbExclamation, "ENTER SENT TO DETAILS BEFORE
CONTINUING"
Canel = True
Me.SentTo.SetFocus
End If
If IsNull(Me.CopiedTo) Then
MsgBox conMESSAGE, vbExclamation, "ENTER COPIED TO DETAILS BEFORE
CONTINUING"
Canel = True
Me.CopiedTo.SetFocus
End If
If IsNull(Me.DateSent) Then
MsgBox conMESSAGE, vbExclamation, "ENTER DATE AS DD/MM/YYYY BEFORE
CONTINUING"
Canel = True
Me.DateSent.SetFocus
End If
If IsNull(Me.CompanyNames) Then
MsgBox conMESSAGE, vbExclamation, "ENTER COMPANY NAME DETAILS BEFORE
CONTINUING"
Canel = True
Me.CompanyNames.SetFocus
End If
If IsNull(Me.Subject) Then
MsgBox conMESSAGE, vbExclamation, "ENTER SUBJECT DETAILS BEFORE
CONTINUING"
Canel = True
Me.Subject.SetFocus
End If
If IsNull(Me.Hyperlink1) Then
MsgBox conMESSAGE, vbExclamation, "ENTER HYPERLINK BEFORE CONTINUING"
Canel = True
Me.Hyperlink1.SetFocus
End If
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Switchboard"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_ReturntoMainMenu_Click:
Exit Sub
Err_ReturntoMainMenu_Click:
MsgBox Err.Description
Resume Exit_ReturntoMainMenu_Click
End Sub