Option Compare Database
Option Explicit
Private Sub Form_Open(Cancel As Integer)
'This code executed as soon as Print Orders and Labels from Form opens.
LabelsToSkip.Enabled = True
SpinUpButton.Visible = True
SpinDownButton.Visible = True
End Sub
Private Sub LabelOption_AfterUpdate()
If LabelOption = 3 Then
LabelsToSkip.Enabled = False
SpinUpButton.Visible = False
SpinDownButton.Visible = False
End If
If LabelOption <> 3 Then
LabelsToSkip.Enabled = True
SpinUpButton.Visible = True
SpinDownButton.Visible = True
End If
End Sub
Private Sub PrintFromOrderForm_Click()
Dim filterCondition As String, Reply As Integer, msg As String, x As Byte
'Default filter is Current Record Only".
filterCondition = "frmPrintfromOrder.PromoPackPK=" & CLng(Me.PromoPackPK)
'First do the order options.
If OrderOption < 3 Then 'Order option 3 is Don't Print Any Invoices Receipts.
If OrderOption = 2 Then 'If second Invoice/Receipt Option selected...
filterCondition = "Not [MemoPrinted]" '...change filter to "Unprinted invoices/receipts.
End If
'Print the Invoices and receipts with appropriate filter condition.
DoCmd.OpenReport "PromoPackMemo", acPreview, "", "", acNormal
'Ask, and make invRecPrinted True if user clicks the Yes button.
Dim Message, Buttons, Choice
Message = "Are you sure you want to complete this order?"
Buttons = vbYesNo
Choice = MsgBox(Message, Buttons)
If Choice = vbYes Then
[tblPromoPack].[MemoPrinted] = True
If Choice = vbNo Then
Exit Sub
'Now on to selected label options.
If LabelOption < 3 Then
If LabelOption = 2 Then 'If All Unprinted Labels selected...
filterCondition = "Not [LabelPrinted]" '...set filter to unprinted labels.
End If
'Put up a reminder about loading labels. Accept Cancel to bail out.
msg = "Please load labels into printer, then click OK."
If MsgBox(msg, vbInformation + vbOKCancel, "Printer") = vbCancel Then
Exit Sub
End If
End If
End If
End If
End If
End Sub
'Code for spin buttons (up). Button is a command button
'with a little bitmap image of an up-pointing arrow.
Function Print_from_Order_Form_Macros_SpinUp()
LabelsToSkip = LabelsToSkip.Value + 1
End Function
Private Sub CancelPrint_Click()
DoCmd.Close acForm, "frmPrintfromOrder", acSaveNo
End Sub