D
DS
I have this code that works, but as always, can it be better?
Any suggestion or help is apprecited.
Thanks
DS
Dim PO As Integer
Me.TxtNumber = Nz(DMax("PDPrinterID", "tblPrintDetails", "PDCheckID = "
& Me.TxtCheckID & ""), 0)
Me.TxtName = DLookup("PrinterName", "tblPrinters", "PrinterID = " &
Me.TxtNumber & "")
For PO = 0 To Nz(Me.TxtNumber - 1, 0)
Me.TxtName = Nz(DLookup("PrinterName", "tblPrinters", "PrinterID = " &
Me.TxtNumber & ""), "")
If IsNull(Me.TxtName) Or _
Me.TxtName = "" Then
Me.TxtName = ""
Else:
Set Application.Printer = Application.Printers(Me.TxtName.Value)
DoCmd.OpenReport "rptPrepSlip", , , "PDCheckID = " &
Me.TxtCheckID &" & _
"And PDPrinterID = " & Me.TxtNumber & ""
Me.TxtNumber = Me.TxtNumber - 1
Me.TxtEmpty = Nz(DCount("PDPrinterID", "tblPrintDetails",
"PDPrinterID = " & Me.TxtNumber & " AND PDCheckID = " & Me.TxtCheckID &
""), 0)
If IsNull(Me.TxtEmpty) Or _
Me.TxtEmpty = "" Or _
Me.TxtEmpty = 0 Then
Me.TxtNumber = Me.TxtNumber - 1
Else:
End If
Set Application.Printer = Nothing
End If
Next PO
Any suggestion or help is apprecited.
Thanks
DS
Dim PO As Integer
Me.TxtNumber = Nz(DMax("PDPrinterID", "tblPrintDetails", "PDCheckID = "
& Me.TxtCheckID & ""), 0)
Me.TxtName = DLookup("PrinterName", "tblPrinters", "PrinterID = " &
Me.TxtNumber & "")
For PO = 0 To Nz(Me.TxtNumber - 1, 0)
Me.TxtName = Nz(DLookup("PrinterName", "tblPrinters", "PrinterID = " &
Me.TxtNumber & ""), "")
If IsNull(Me.TxtName) Or _
Me.TxtName = "" Then
Me.TxtName = ""
Else:
Set Application.Printer = Application.Printers(Me.TxtName.Value)
DoCmd.OpenReport "rptPrepSlip", , , "PDCheckID = " &
Me.TxtCheckID &" & _
"And PDPrinterID = " & Me.TxtNumber & ""
Me.TxtNumber = Me.TxtNumber - 1
Me.TxtEmpty = Nz(DCount("PDPrinterID", "tblPrintDetails",
"PDPrinterID = " & Me.TxtNumber & " AND PDCheckID = " & Me.TxtCheckID &
""), 0)
If IsNull(Me.TxtEmpty) Or _
Me.TxtEmpty = "" Or _
Me.TxtEmpty = 0 Then
Me.TxtNumber = Me.TxtNumber - 1
Else:
End If
Set Application.Printer = Nothing
End If
Next PO