I have a query which I view through a form. Due to problems with the label wizard printing to a dot-matrix printer I have some code to print out a single label when a command button is clicked. This works fine.
However I would like to print all the records from the query on to consecutive labels.
Below is the code for this function but it doesn't work (surprise, surprise). I probably don't need the form in the code as it is looking at the query. Can someone give me some advice please? Many thanks.
However I would like to print all the records from the query on to consecutive labels.
Below is the code for this function but it doesn't work (surprise, surprise). I probably don't need the form in the code as it is looking at the query. Can someone give me some advice please? Many thanks.
Code:
Public Function fcmdPrint3_Click()
On Error GoTo Err_cmdPrint3_Click
Dim t_module As String
Dim t_Name As String
Dim t_ADDRESS1 As String
Dim t_ADDRESS2 As String
Dim t_ADDRESS3 As String
Dim t_POSTCODE
Set t_module = [Forms]![Shipping Labels]![txtmodule]
Set t_Name = [Forms]![Shipping Labels]![txtname]
Set t_ADDRESS1 = [Forms]![Shipping Labels]![txtaddress1]
Set t_ADDRESS2 = [Forms]![Shipping Labels]![txtaddress2]
Set t_ADDRESS3 = [Forms]![Shipping Labels]![txtaddress3]
Set t_POSTCODE = [Forms]![Shipping Labels]![txtPostcode]
Dim rst As Recordset
Set rst = db.openrecordset("Daily_Shipping_Query")
With rst
Do Until rst.EOF
Open "LPT1:" For Output As #1
Print #1, t_module
Print #1, t_Name
Print #1, t_ADDRESS1
Print #1, t_ADDRESS2
Print #1, t_ADDRESS3
Print #1, t_POSTCODE
rst.MoveNext
Loop
Close #1
rst.MoveFirst
Close
End With
Exit_cmdPrint3_Click:
Exit Function
Err_cmdPrint3_Click:
MsgBox Err.Description
Resume Exit_cmdPrint3_Click
End Function
Comment