D
DS
I have this statement that keeps getting hung up on the loop. It says
that I must have a DO, which I have but I guess somethings in the wrong
place. Any help appreciated.
Thanks
DS
Dim PO As Integer
'GET HIGHEST PRINTER
Me.TxtNumber = Nz(DMax("PDPrinterID", "tblPrintDetails", "PDCheckID = "
& Me.TxtCheckID), 0)
On Error GoTo ErrorHandler
'THEN START LOOP
Do
'LOOK FOR EMPTY CHECK
Me.TxtEmpty = Nz(DCount("PDPrinterID", "tblPrintDetails", "PDPrinterID =
" & Me.TxtNumber & " " & _
"AND PDCheckID = " & Me.TxtCheckID), 0)
'IF CHECK IS EMPTY THEN REDUCE PRINTERID BY 1
If IsNull(Me.TxtEmpty) Or _
Me.TxtEmpty = 0 Then
Me.TxtNumber = Me.TxtNumber - 1
Else:
'IF CHECK NOT EMPTY THEN CHECK FOR CONDITIONAL
Me.TxtCon = Nz(DLookup("PDCon", "tblPrintDetails", "PDPrinterID = " &
Me.TxtNumber), 0)
If Me.TxtCon = -1 Then
'IF CONDITIONAL IS -1 THEN GET CURRENT ITEM NUMBER
Me.TxtItemID = Nz(DLookup("PDItemID", "tblPrintDetails", "PDPrinterID =
" & Me.TxtNumber), 0)
'THEN COUNT OTHER ITEMID'S WITH SAME PRINTERID AND SAME CHECKID
Me.TxtGo = Nz(DCount("PDItemID", "tblPrintDetails", "PDItemID <> " &
Me.TxtItemID & " And PDPrinterID = " & Me.TxtNumber & "And PDCheckID = "
& Me.TxtCheckID), 0)
'IF COUNT IS EQUAL OR GREATER THAN 1 THEN PRINT, OTHERWISE END
If Me.TxtGo >= 1 Then
Me.TxtName = Nz(DLookup("PrinterName", "tblPrinters", "PrinterID = " &
Me.TxtNumber), "")
If Not Me.TxtName = "No Print" Then
If Not Me.TxtName = "" Then
'IF NOT "NO PRINT" THEN PRINT!
Set Application.Printer = Application.Printers(Me.TxtName.Value)
DoCmd.OpenReport "rptTwo", , , "PDCheckID = " & Me.TxtCheckID & " And
PDPrinterID = " & Me.TxtNumber & ""
Me.TxtNumber = Me.TxtNumber - 1
Set Application.Printer = Nothing
End If
ElseIf Me.TxtGo = 0 Then
End If
ElseIf Me.TxtCon = 0 Then
Me.TxtName = Nz(DLookup("PrinterName", "tblPrinters", "PrinterID = " &
Me.TxtNumber), "")
If Not Me.TxtName = "No Print" Then
If Not Me.TxtName = "" Then
Set Application.Printer = Application.Printers(Me.TxtName.Value)
DoCmd.OpenReport "rptTwo", , , "PDCheckID = " & Me.TxtCheckID & " And
PDPrinterID = " & Me.TxtNumber & ""
Me.TxtNumber = Me.TxtNumber - 1
Set Application.Printer = Nothing
End If
End If
Loop Until Me.TxtNumber = 0
End
ErrorHandler:
DoCmd.OpenForm "frmMsgWarning"
Forms!frmMsgWarning!TxtMsg = "INVALID PRINTER"
End Sub
that I must have a DO, which I have but I guess somethings in the wrong
place. Any help appreciated.
Thanks
DS
Dim PO As Integer
'GET HIGHEST PRINTER
Me.TxtNumber = Nz(DMax("PDPrinterID", "tblPrintDetails", "PDCheckID = "
& Me.TxtCheckID), 0)
On Error GoTo ErrorHandler
'THEN START LOOP
Do
'LOOK FOR EMPTY CHECK
Me.TxtEmpty = Nz(DCount("PDPrinterID", "tblPrintDetails", "PDPrinterID =
" & Me.TxtNumber & " " & _
"AND PDCheckID = " & Me.TxtCheckID), 0)
'IF CHECK IS EMPTY THEN REDUCE PRINTERID BY 1
If IsNull(Me.TxtEmpty) Or _
Me.TxtEmpty = 0 Then
Me.TxtNumber = Me.TxtNumber - 1
Else:
'IF CHECK NOT EMPTY THEN CHECK FOR CONDITIONAL
Me.TxtCon = Nz(DLookup("PDCon", "tblPrintDetails", "PDPrinterID = " &
Me.TxtNumber), 0)
If Me.TxtCon = -1 Then
'IF CONDITIONAL IS -1 THEN GET CURRENT ITEM NUMBER
Me.TxtItemID = Nz(DLookup("PDItemID", "tblPrintDetails", "PDPrinterID =
" & Me.TxtNumber), 0)
'THEN COUNT OTHER ITEMID'S WITH SAME PRINTERID AND SAME CHECKID
Me.TxtGo = Nz(DCount("PDItemID", "tblPrintDetails", "PDItemID <> " &
Me.TxtItemID & " And PDPrinterID = " & Me.TxtNumber & "And PDCheckID = "
& Me.TxtCheckID), 0)
'IF COUNT IS EQUAL OR GREATER THAN 1 THEN PRINT, OTHERWISE END
If Me.TxtGo >= 1 Then
Me.TxtName = Nz(DLookup("PrinterName", "tblPrinters", "PrinterID = " &
Me.TxtNumber), "")
If Not Me.TxtName = "No Print" Then
If Not Me.TxtName = "" Then
'IF NOT "NO PRINT" THEN PRINT!
Set Application.Printer = Application.Printers(Me.TxtName.Value)
DoCmd.OpenReport "rptTwo", , , "PDCheckID = " & Me.TxtCheckID & " And
PDPrinterID = " & Me.TxtNumber & ""
Me.TxtNumber = Me.TxtNumber - 1
Set Application.Printer = Nothing
End If
ElseIf Me.TxtGo = 0 Then
End If
ElseIf Me.TxtCon = 0 Then
Me.TxtName = Nz(DLookup("PrinterName", "tblPrinters", "PrinterID = " &
Me.TxtNumber), "")
If Not Me.TxtName = "No Print" Then
If Not Me.TxtName = "" Then
Set Application.Printer = Application.Printers(Me.TxtName.Value)
DoCmd.OpenReport "rptTwo", , , "PDCheckID = " & Me.TxtCheckID & " And
PDPrinterID = " & Me.TxtNumber & ""
Me.TxtNumber = Me.TxtNumber - 1
Set Application.Printer = Nothing
End If
End If
Loop Until Me.TxtNumber = 0
End
ErrorHandler:
DoCmd.OpenForm "frmMsgWarning"
Forms!frmMsgWarning!TxtMsg = "INVALID PRINTER"
End Sub