J
Jon
Hi I have some code, reproduced below that should prevent an invoice
printing with a 0 rate.
however, if, for example, there are two items with zero rate the code asks
the question twice but carries on printing anyway!
Can anyone advise how I change the code to stop when the user presses yes?
Thanks
Jon
================================== The Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim response As String
If CalculatedCost = "0" Or Len(Trim$(CalculatedCost & vbNullString)) = 0
Then
response = MsgBox("There is an cost of 0 (zero) or empty, the invoice cannot
proceded, would you like to fix that now?", vbYesNo + vbQuestion +
vbDefaultButton2)
If response = vbYes Then ' User chose Yes.
DoCmd.Close acReport, Me.Name
Dim stLinkCriteria As String
stLinkCriteria = "[InvoiceId]=" & Me![InvoiceId]
DoCmd.OpenForm "FrmInvoiceBuilder", , , stLinkCriteria, , acDialog
Exit Sub
Else ' User chose No.
DoCmd.Close acReport, Me.Name
Exit Sub
End If
End If
End Sub
printing with a 0 rate.
however, if, for example, there are two items with zero rate the code asks
the question twice but carries on printing anyway!
Can anyone advise how I change the code to stop when the user presses yes?
Thanks
Jon
================================== The Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim response As String
If CalculatedCost = "0" Or Len(Trim$(CalculatedCost & vbNullString)) = 0
Then
response = MsgBox("There is an cost of 0 (zero) or empty, the invoice cannot
proceded, would you like to fix that now?", vbYesNo + vbQuestion +
vbDefaultButton2)
If response = vbYes Then ' User chose Yes.
DoCmd.Close acReport, Me.Name
Dim stLinkCriteria As String
stLinkCriteria = "[InvoiceId]=" & Me![InvoiceId]
DoCmd.OpenForm "FrmInvoiceBuilder", , , stLinkCriteria, , acDialog
Exit Sub
Else ' User chose No.
DoCmd.Close acReport, Me.Name
Exit Sub
End If
End If
End Sub