G
Gabby Girl
Good morning,
I have the following code attached to a command button that up to yesterday
did what it was supposed to do (sort of):
********************************
Private Sub cmdPrint_Click()
On Error GoTo Err_cmdPrint_Click
Dim stDocName As String
Dim Cancel As Boolean
stDocName = "rptPickTicket"
If IsNull(Me.cboRONbr) or (Me.cboRONbr) = 0 Then
MsgBox "You must have a workorder nbr before you can print a pick
ticket!", vbOKOnly, "Stop!"
Exit Sub
End If
Else
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport stDocName, acViewPreview, , "[qrptPickTicket].[PTId] =
" & Me![PTId]
Me.EquipmentId.SetFocus
Me.cmdPrint.Visible = False
Me.cmdAddPT.Visible = True
Exit_cmdPrint_Click:
Exit Sub
Err_cmdPrint_Click:
MsgBox Err.Description
Resume Exit_cmdPrint_Click
End Sub
*************************
I had to modify the above to allow certain pick tickets to print with
cboRONbr = 0
as long as the Equipment nbrs began with 3 certain letters.
Here is the modified code. Which now does nothing at all.
********************************
Private Sub cmdPrint_Click()
On Error GoTo Err_cmdPrint_Click
Dim stDocName As String
Dim Cancel As Boolean
stDocName = "rptPickTicket"
If Me.EquipmentId Like "*N*" Or Me.EquipmentId Like "*HV*" Or
Me.EquipmentId Like "*P*" And Me.cboRONbr = 0 Then
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport stDocName, acViewPreview, , "[qrptPickTicket].[PTId] =
" & Me![PTId]
Me.EquipmentId.SetFocus
Me.cmdPrint.Visible = False
Me.cmdAddPT.Visible = True
ElseIf Nz(Me.cboRONbr) And Me.EquipmentId Like "*C*" Or Me.EquipmentId
Like "*CE*" Or Me.EquipmentId Like "*E*" Or Me.EquipmentId Like "*F*" Or
Me.EquipmentId Like "*R*" Then
MsgBox "You must have a workorder nbr before you can print a pick
ticket!", vbOKOnly, "Stop!"
Exit Sub
End If
Exit_cmdPrint_Click:
Exit Sub
Err_cmdPrint_Click:
MsgBox Err.Description
Resume Exit_cmdPrint_Click
End Sub
**********************************
Basically what we need is :
1) Print pick ticket if cboRONbr is 0 AND EquipmentId begins with either a
"N,"P' or HV"
2) Don't print pick ticket if cboRONbr is 0 AND EquipmentId begins with
anything other than the 3 listed above.
I've tried a variety of things suggested by others & can't seem to get
anything to work. I'm sure the solution is staring me in the face, but I
can't seem to figure it.
Any help, as always, will be greatly appreciated.
Thanks Kindly
I have the following code attached to a command button that up to yesterday
did what it was supposed to do (sort of):
********************************
Private Sub cmdPrint_Click()
On Error GoTo Err_cmdPrint_Click
Dim stDocName As String
Dim Cancel As Boolean
stDocName = "rptPickTicket"
If IsNull(Me.cboRONbr) or (Me.cboRONbr) = 0 Then
MsgBox "You must have a workorder nbr before you can print a pick
ticket!", vbOKOnly, "Stop!"
Exit Sub
End If
Else
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport stDocName, acViewPreview, , "[qrptPickTicket].[PTId] =
" & Me![PTId]
Me.EquipmentId.SetFocus
Me.cmdPrint.Visible = False
Me.cmdAddPT.Visible = True
Exit_cmdPrint_Click:
Exit Sub
Err_cmdPrint_Click:
MsgBox Err.Description
Resume Exit_cmdPrint_Click
End Sub
*************************
I had to modify the above to allow certain pick tickets to print with
cboRONbr = 0
as long as the Equipment nbrs began with 3 certain letters.
Here is the modified code. Which now does nothing at all.
********************************
Private Sub cmdPrint_Click()
On Error GoTo Err_cmdPrint_Click
Dim stDocName As String
Dim Cancel As Boolean
stDocName = "rptPickTicket"
If Me.EquipmentId Like "*N*" Or Me.EquipmentId Like "*HV*" Or
Me.EquipmentId Like "*P*" And Me.cboRONbr = 0 Then
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport stDocName, acViewPreview, , "[qrptPickTicket].[PTId] =
" & Me![PTId]
Me.EquipmentId.SetFocus
Me.cmdPrint.Visible = False
Me.cmdAddPT.Visible = True
ElseIf Nz(Me.cboRONbr) And Me.EquipmentId Like "*C*" Or Me.EquipmentId
Like "*CE*" Or Me.EquipmentId Like "*E*" Or Me.EquipmentId Like "*F*" Or
Me.EquipmentId Like "*R*" Then
MsgBox "You must have a workorder nbr before you can print a pick
ticket!", vbOKOnly, "Stop!"
Exit Sub
End If
Exit_cmdPrint_Click:
Exit Sub
Err_cmdPrint_Click:
MsgBox Err.Description
Resume Exit_cmdPrint_Click
End Sub
**********************************
Basically what we need is :
1) Print pick ticket if cboRONbr is 0 AND EquipmentId begins with either a
"N,"P' or HV"
2) Don't print pick ticket if cboRONbr is 0 AND EquipmentId begins with
anything other than the 3 listed above.
I've tried a variety of things suggested by others & can't seem to get
anything to work. I'm sure the solution is staring me in the face, but I
can't seem to figure it.
Any help, as always, will be greatly appreciated.
Thanks Kindly