Hi all,
Using Access 2K
For reference, all fields listed below are text boxes on my form that are used in the code:
LabelName
NoOfLabels - No of times to copy recordset to textfile (loop)
ProperShippingName
UN_No
PrinterName
TextFileName
I am currently have the following code attached to a button that when pressed creates a text file. The code works fine but I have trouble with inserting multiple copies of the recordset to the textfile.
Dim i As Integer
Dim hFileHandle As Long
Dim Path As String
Path = Me.TextFileName.Value
For i = 1 To NoOfLabels
hFileHandle = FreeFile
Open Path For Output As #hFileHandle
Write #hFileHandle, "*FORMAT, " & LabelName & vbCrLf
Write #hFileHandle, "ProperShippingName, " & Me.ProperShippingName.Value & vbCrLf
Write #hFileHandle, "UN_No, " & UN_No & vbCrLf
Write #hFileHandle, "*PRINTERNAME, " & PrinterName & vbCrLf
Write #hFileHandle, "*PRINTLABEL"
Close #hFileHandle
Next i
End Sub
My problem obviously is that if I specify that I need two copies of the label. What should happen is that the record should be copied to the text file twice like so:
*FORMAT, miniQSDSPLBL.lwl
ProperShippingName, Corrosive Liquid N.O.S.(Contains Sodium Hydroxide)
UN_No, 1760
*PRINTERNAME, station4
*PRINTLABEL
*FORMAT, miniQSDSPLBL.lwl
ProperShippingName, Corrosive Liquid N.O.S.(Contains Sodium Hydroxide)
UN_No, 1760
*PRINTERNAME, station4
*PRINTLABEL
Because of the incorrect way that I wrote the code, the first instance is overwritten when the second instance is inserted. So there is always only one record in the text file when I open it.
Does anyone have any better ideas on how I could rewrite my code to achieve this?
Rgrds, Tadynn
Using Access 2K
For reference, all fields listed below are text boxes on my form that are used in the code:
LabelName
NoOfLabels - No of times to copy recordset to textfile (loop)
ProperShippingName
UN_No
PrinterName
TextFileName
I am currently have the following code attached to a button that when pressed creates a text file. The code works fine but I have trouble with inserting multiple copies of the recordset to the textfile.
Dim i As Integer
Dim hFileHandle As Long
Dim Path As String
Path = Me.TextFileName.Value
For i = 1 To NoOfLabels
hFileHandle = FreeFile
Open Path For Output As #hFileHandle
Write #hFileHandle, "*FORMAT, " & LabelName & vbCrLf
Write #hFileHandle, "ProperShippingName, " & Me.ProperShippingName.Value & vbCrLf
Write #hFileHandle, "UN_No, " & UN_No & vbCrLf
Write #hFileHandle, "*PRINTERNAME, " & PrinterName & vbCrLf
Write #hFileHandle, "*PRINTLABEL"
Close #hFileHandle
Next i
End Sub
My problem obviously is that if I specify that I need two copies of the label. What should happen is that the record should be copied to the text file twice like so:
*FORMAT, miniQSDSPLBL.lwl
ProperShippingName, Corrosive Liquid N.O.S.(Contains Sodium Hydroxide)
UN_No, 1760
*PRINTERNAME, station4
*PRINTLABEL
*FORMAT, miniQSDSPLBL.lwl
ProperShippingName, Corrosive Liquid N.O.S.(Contains Sodium Hydroxide)
UN_No, 1760
*PRINTERNAME, station4
*PRINTLABEL
Because of the incorrect way that I wrote the code, the first instance is overwritten when the second instance is inserted. So there is always only one record in the text file when I open it.
Does anyone have any better ideas on how I could rewrite my code to achieve this?
Rgrds, Tadynn