In the input box if we click ok or cancel the invoice prints. By default the credit card info is 0, and most of the cases its 0 even when we want to take a print out i.e., the value is changed.
I tried doing If Payment = "" Then Exit sub,
but it exits the sub if I press ok or cancel since the credit card value is not changed and remains to be 0.
What changes can I make so that if OK is clicked the document prints and if cancel is clicks it exits the sub, even if credit card value continues to remain 0. Its very very urgent!
I tried doing If Payment = "" Then Exit sub,
but it exits the sub if I press ok or cancel since the credit card value is not changed and remains to be 0.
What changes can I make so that if OK is clicked the document prints and if cancel is clicks it exits the sub, even if credit card value continues to remain 0. Its very very urgent!
Code:
Private Sub PRINT_Click() On Error Resume Next ' CopyNumber is global Dim NumCopies As Integer, ReportDest As Integer, Msg As String, Payment As Currency, Response As String 'Hide the Invoice Print Dialog Forms![yInvoice Print Dialog].Visible = False ' Destination is Print Preview If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Type of Output] = 1 Then ReportDest = A_PREVIEW Else ' Destination is printer ReportDest = A_NORMAL End If NumCopies = Forms![yInvoice Print Dialog]![TabSubfrm].Form![Number Copies].Value PrintMessages = Forms![yInvoice Print Dialog]![TabSubfrm].Form![Print Messages].Value PrintPayments = Forms![yInvoice Print Dialog]![TabSubfrm].Form![Print Payments].Value ' Determine Print Criteria selected Msg = "How much is being paid by" & vbCrLf & "Credit Card on this Invoice?" Payment = InputBox(Msg, "Credit Card Payment", 0) Select Case Forms![yInvoice Print Dialog]![TabSubfrm].Form![Type of Print] Case 1 ' Current Record ' Print Standard Invoice If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Invoice] = -1 Then For CopyNumber = 1 To (NumCopies - 1) If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Separate Shipments] Then DoCmd.OpenReport "Invoice -Separated", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]" Else DoCmd.OpenReport "Invoice", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]", , Payment End If Next CopyNumber DoCmd.OpenReport "Invoice-Unsigned", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]", , Payment End If ' Print Pro Forma Invoice If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Pro Forma Invoice] = -1 Then For CopyNumber = 1 To NumCopies If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Separate Shipments] Then DoCmd.OpenReport "Invoice -Separated", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]" Else DoCmd.OpenReport "Invoice-ProForma Title", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]", , Payment End If Next CopyNumber End If ' Print Packing List If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Packing List] = -1 Then For CopyNumber = 1 To NumCopies DoCmd.OpenReport "Packing List", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]" Next CopyNumber End If ' Print Commercial Invoice one copy only If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Commercial Invoice] = -1 Then DoCmd.OpenReport "Invoice-Customs", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]", , Payment End If Case 2 ' Date Range ' Print Standard Invoice If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Invoice] = -1 Then For CopyNumber = 1 To NumCopies If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Separate Shipments] Then DoCmd.OpenReport "Invoice -Separated", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Invoice]![Invoice Date] Between [Forms]![yInvoice Print Dialog]![TabsubFrm].Form![From Date] And [Forms]![yInvoice Print Dialog]![TabsubFrm].Form![To Date])" Else DoCmd.OpenReport "Invoice", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Invoice]![Invoice Date] Between [Forms]![yInvoice Print Dialog]![TabsubFrm].Form![From Date] And [Forms]![yInvoice Print Dialog]![TabsubFrm].Form![To Date])" End If Next CopyNumber End If ' Print Simple Invoice 'If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Simple Invoice] = -1 Then ' For CopyNumber = 1 To NumCopies ' If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Separate Shipments] Then ' DoCmd.OpenReport "Invoice Single Line -Separated", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Invoice]![Invoice Date] Between [Forms]![yInvoice Print Dialog]![TabsubFrm].Form![From Date] And [Forms]![yInvoice Print Dialog]![TabsubFrm].Form![To Date])" ' Else ' DoCmd.OpenReport "Invoice Single Line", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Invoice]![Invoice Date] Between [Forms]![yInvoice Print Dialog]![TabsubFrm].Form![From Date] And [Forms]![yInvoice Print Dialog]![TabsubFrm].Form![To Date])" ' End If ' Next CopyNumber 'End If ' Print Preprinted Form If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Preprinted Form] = -1 Then For CopyNumber = 1 To NumCopies If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Separate Shipments] Then DoCmd.OpenReport "Invoice Just Data -Separated", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Invoice]![Invoice Date] Between [Forms]![yInvoice Print Dialog]![TabsubFrm].Form![From Date] And [Forms]![yInvoice Print Dialog]![TabsubFrm].Form![To Date])" Else DoCmd.OpenReport "Invoice Just Data", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Invoice]![Invoice Date] Between [Forms]![yInvoice Print Dialog]![TabsubFrm].Form![From Date] And [Forms]![yInvoice Print Dialog]![TabsubFrm].Form![To Date])" End If Next CopyNumber End If Case 3 ' Customer Number ' Print Standard Invoice If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Invoice] = -1 Then For CopyNumber = 1 To NumCopies If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Separate Shipments] Then DoCmd.OpenReport "Invoice -Separated", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Sold to Customer]=[Forms]![yInvoice Print Dialog]![TabsubFrm].Form![Customer Number])" Else DoCmd.OpenReport "Invoice", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Sold to Customer]=[Forms]![yInvoice Print Dialog]![TabsubFrm].Form![Customer Number])" End If Next CopyNumber End If ' Print Pro Forma Invoice If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Pro Forma Invoice] = -1 Then For CopyNumber = 1 To NumCopies If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Separate Shipments] Then DoCmd.OpenReport "Invoice -Separated", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]" Else DoCmd.OpenReport "Invoice-ProForma Title", ReportDest, , "[Invoice]![Invoice Number]=[Forms]![Invoice]![Invoice Number]", , Payment End If Next CopyNumber End If ' Print Preprinted Form If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Preprinted Form] = -1 Then For CopyNumber = 1 To NumCopies If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Separate Shipments] Then DoCmd.OpenReport "Invoice Just Data -Separated", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Sold to Customer]=[Forms]![yInvoice Print Dialog]![TabsubFrm].Form![Customer Number])" Else DoCmd.OpenReport "Invoice Just Data", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Sold to Customer]=[Forms]![yInvoice Print Dialog]![TabsubFrm].Form![Customer Number])" End If Next CopyNumber End If ' Print Mailing Labels If Forms![yInvoice Print Dialog]![TabSubfrm].Form![Commercial Invoice] = -1 Then DoCmd.OpenReport "Invoice-Customs", ReportDest, , "([Invoice Type] = 'F' OR [Invoice Type] = 'I') AND ([Sold to Customer]=[Forms]![yInvoice Print Dialog]![TabsubFrm].Form![Customer Number])" End If End Select ' DoCmd.Close A_FORM, "yInvoice Print Dialog" End Sub
Comment