Here is my code:
Code:
Private Sub Command38_Click()On Error GoTo Err_Command38_Click
If InStr(1, Me.[Machine#], "-1") > 0 Or InStr(1, Me.[Machine#], "-6") > 0 Or InStr(1, Me.[Machine#], "-7") > 0 Or InStr(1, Me.[Machine#], "-8") > 0 Or InStr(1, Me.[Machine#], "-9") > 0 Or InStr(1, Me.[Machine#], "-13") > 0 Then
Dim stDocName As String
stDocName = "Process Info Main"
DoCmd.OpenReport stDocName, acNormal
ElseIf InStr(1, Me.[Machine#], "-2") > 0 Or InStr(1, Me.[Machine#], "-3") > 0 Or InStr(1, Me.[Machine#], "-4") > 0 Or InStr(1, Me.[Machine#], "-5") > 0 Or InStr(1, Me.[Machine#], "-11") > 0 Or InStr(1, Me.[Machine#], "-12") > 0 Or InStr(1, Me.[Machine#], "-14") > 0 Or InStr(1, Me.[Machine#], "-15") > 0 Or InStr(1, Me.[Machine#], "-16") > 0 Or InStr(1, Me.[Machine#], "-17") > 0 Or InStr(1, Me.[Machine#], "-18") > 0 Or InStr(1, Me.[Machine#], "-19") > 0 Then
stDocName = "rptPrintMasterSetUpSheet"
DoCmd.OpenReport stDocName, acNormal
Exit_Command38_Click:
Exit Sub
Err_Command38_Click:
MsgBox Err.Description
Resume Exit_Command38_Click
End If
End Sub
It is used on a print button on a form. It used to work when I didn't have to be so specific with the numbers (-16, -17, etc) but now I had to put in the ElseIf instead of just the Else it used to be and when a user clicks the print button, nothing happens. In the code editor the macro button keeps popping up when I click Run Code. Here is my old working code:
Code:
Private Sub Command38_Click()
On Error GoTo Err_Command38_Click
If InStr(1, Me.[ID#], "55.1") > 0 Or InStr(1, Me.[ID#], "110.1") > 0 Or InStr(1, Me.[ID#], "110.2") > 0 Or InStr(1, Me.[ID#], "110.3") > 0 Or InStr(1, Me.[ID#], "110.4") > 0 Or InStr(1, Me.[ID#], "165.1") > 0 Then
Dim stDocName As String
stDocName = "Process Info Main"
DoCmd.OpenReport stDocName, acNormal
Else
stDocName = "rptPrintMasterSetUpSheet"
DoCmd.OpenReport stDocName, acNormal
Exit_Command38_Click:
Exit Sub
Err_Command38_Click:
MsgBox Err.Description
Resume Exit_Command38_Click
End If
End Sub
What is my problem?!