|
View Screenshot – View VBA Code |
|
VBA code to print and, if necessary, update order status |
|
Private Sub BtnPrint_Click() If Not DebugMode Then On Error GoTo SubErrHandler Dim Confirm As Integer Dim PrintDespatchNote, PrintInvoice As Integer 'If user has selected to print the invoice... If Me.chkInvoice = True Then If IsNull(Form_FormSalesDespatch.txtInvoiceDate) Then 'If order has not already been marked as invoiced, ask user to confirm before proceeding Confirm = MsgBox("Click OK to print, and mark this" & vbCrLf & _ "order as despatched and invoiced." & vbCrLf & _ vbCrLf & "Proceed?", vbOKCancel + vbQuestion, "Confirm") If Confirm = vbOK Then Call MarkAsDespatched 'Mark as despatched by the user currently logged in Call MarkAsInvoiced 'Mark as invoiced by the user currently logged in PrintInvoice = vbOK Call Form_FormSalesDespatch.SDStatusFlagRefresh End If Else PrintInvoice = vbOK End If Me.BtnCancel.Caption = "Close" 'Change the Cancel button from "Cancel" to "Close" End If If PrintInvoice = vbOK Then DoCmd.OpenReport "RptSalesInvoice", acViewNormal 'Clear the hidden "Invoice previewed" flag (used on form_close) Me.chkInvoicePreviewed = False End If 'Clear the variables Confirm = vbCancel 'If user has selected to print the despatch note... If Me.chkDespatchNote = True Then 'If order has not already been marked as despatched, ask user to confirm before proceeding If IsNull(Form_FormSalesDespatch.txtDespatchDate) Then Confirm = MsgBox("Click OK to print, and mark" & vbCrLf & _ "this order as despatched." & vbCrLf & vbCrLf & _ "Proceed?", vbOKCancel + vbQuestion, "Confirm") If Confirm = vbOK Then Call MarkAsDespatched PrintDespatchNote = vbOK Call Form_FormSalesDespatch.SDStatusFlagRefresh 'update order status flag End If Else PrintDespatchNote = vbOK End If Me.BtnCancel.Caption = "Close" 'Change the Cancel button from "Cancel" to "Close" End If If PrintDespatchNote = vbOK Then DoCmd.OpenReport "RptSalesDespatch", acViewNormal 'i.e. send to default printer 'Clear the hidden "despatch note previewed" flag (used on form_close) Me.chkDespatchNotePreviewed = False End If Exit_Sub: Exit Sub SubErrHandler: Call ErrorHandler("BtnPrint_Click", "FormSalesDespatch options", Err, Error) 'central error handler in module modErrorHandling Resume Exit_Sub End Sub> |
|
All rights reserved worldwide © 2009- Synstral Business Software HB, Storegårdsvägen 2, 534 94 Vara, Sweden |
||
|
Registered in Sweden, No. 969739-9856, EU VAT number SE969739985601 |
|
|