Hi all,
I have a form "frmCardFile" that has a field "cboCustomer" & a command button "cmdViewJobs" that opens up another form "frmJob".
My intention is to stop the user if they click on "cmdViewJobs" from opening "frmJob" if nothing has been selected from "cboCustomer" & to pop-up a msgbox that states something like "you haven't selected anything". If the user then goes back & selects a customer, then clicks cmdOpenJob, the user should then be allowed to open "frmJob". I have the following code in the "onClick" event of "cmdViewJobs":
Private Sub cmdViewJobs_Click()
On Error GoTo Err_cmdViewJobs_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmJob"
If Len(strCriteria) = 0 Then
MsgBox "You did not select anything from the list" _
, vbExclamation
Exit Sub
End If
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdViewJobs_Click:
Exit Sub
Err_cmdViewJobs_Click:
MsgBox Err.Description
Resume Exit_cmdViewJobs_Click
End Sub
I keep getting the message box pop-up whether or not "cboCustomer" is null or not null. Can anyone spot the error in my code.
Thanks in advance.
I have a form "frmCardFile" that has a field "cboCustomer" & a command button "cmdViewJobs" that opens up another form "frmJob".
My intention is to stop the user if they click on "cmdViewJobs" from opening "frmJob" if nothing has been selected from "cboCustomer" & to pop-up a msgbox that states something like "you haven't selected anything". If the user then goes back & selects a customer, then clicks cmdOpenJob, the user should then be allowed to open "frmJob". I have the following code in the "onClick" event of "cmdViewJobs":
Private Sub cmdViewJobs_Click()
On Error GoTo Err_cmdViewJobs_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmJob"
If Len(strCriteria) = 0 Then
MsgBox "You did not select anything from the list" _
, vbExclamation
Exit Sub
End If
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdViewJobs_Click:
Exit Sub
Err_cmdViewJobs_Click:
MsgBox Err.Description
Resume Exit_cmdViewJobs_Click
End Sub
I keep getting the message box pop-up whether or not "cboCustomer" is null or not null. Can anyone spot the error in my code.
Thanks in advance.