Hi,

I need help bad!!

I have the need to be able to print a different number of different labels. Example, Label1 - 2 copies, Label2 - 4 copies, Label3 - 1 copy etc. etc. The attached code loops through the recordset and does just that. It allows the user to start printing labels anywhere on the page - to use up partial sheets of labels. I got the code from the MKB then adjusted it to what I need. When you print preview the report, it works beautiful. When you attempt to print - it will not send the file to the printer and therefore will not print. I removed the line that says 'rec.MoveNext' and the report will print - except it has the wrong number of labels. The information for the labels are kept in a table with the field QTY as the number of labels needed. Can anyone PLEASE help me?!? I think I have a minor concussion from beating my head on the desk.

Thank you in advance for any assistance

Lee
'================================================= =========
' This declares all variables with a Public Scope so that
' all values are kept while the report is open.
'================================================= =========
Option Compare Database
Option Explicit

Dim LabelBlanks&
Dim LabelCopies&
Dim BlankCount&
Dim CopyCount&
Dim i As Integer
Dim db As Database
Dim rec As Recordset

'================================================= =========
' The following function will cause an input box to
' display when the report is run that prompts the user
' for the number of used labels to skip.
'================================================= ==========

Function LabelSetup()

LabelBlanks& = Val(InputBox$("Enter Number of blank labels to skip. Maximum is 29."))


If LabelBlanks& > 0 Then
MsgBox "Please make sure that your sheet of labels is in the printer " _
& "with the first blank label in the upper left hand corner.", _
vbInformation, "Label Setup!!"
End If
If LabelBlanks& < 0 Then LabelBlanks& = 0

End Function
'================================================= ==========
' The following function sets all variables to a zero when
' the report initializes.
'================================================= ==========
Function LabelInitialize()
BlankCount& = 0
i = 0
End Function
'================================================= ==========
' The following function is the main part of this code
' that allows the labels to print as the user desires.
' ================================================== =========
Function LabelLayout(R As Report)
If IsNull(rec("QTY")) Then
CopyCount& = 1
End If
i = i + 1 'this counts number of labels on the report (max 30)

If BlankCount& < LabelBlanks& Then
R.NextRecord = False
R.PrintSection = False
BlankCount& = BlankCount& + 1

Else

If i = 31 Then 'if 31, then reset i to 0, exit and recall for next
'page of report. BlankCount& is kept because of
'public scope, therefore no labels are skipped on the
'remaining pages of the report
i = 0
Exit Function
End If
If CopyCount& < (rec("QTY") - 1) Then
R.NextRecord = False
CopyCount& = CopyCount& + 1
Else
CopyCount& = 0
rec.MoveNext
End If
End If
End Function

Function LabelByDate()

DoCmd.SetWarnings False
DoCmd.OpenQuery "Label By Date", acViewPreview
Set db = CurrentDb()
Set rec = db.OpenRecordset("zLabelByDate")
DoCmd.OpenReport "Label By Date"
DoCmd.SetWarnings True

End Function

Function GenericLabelReport()

Set db = CurrentDb()
Set rec = db.OpenRecordset("OLE 044")
DoCmd.OpenReport "Generic Label Maker", acViewPreview

End Function

Function LabelByMonth()

DoCmd.SetWarnings False
DoCmd.OpenQuery "Label By Month"
Set db = CurrentDb()
Set rec = db.OpenRecordset("zLabelByMonth")
DoCmd.OpenReport "Label By Month", acViewPreview
DoCmd.SetWarnings True

End Function

Function RClose()

rec.Close
End Function