I will try and explain this the best possible way, I have a appl. that prints labels, before printing a label I enter two pieces of data but one is only important as that gets printed on the label as well.
So I click on "Print label" and then this code takes me to RecordLabelPrinter function where I enter and query data
If txtNbrBoxes.Text = "" Then
szText = "one box"
Else
szText = "Box " & CStr(lBox) & " of " & txtNbrBoxes.Text
End If
szLoggerCode = RecordDataLogger(mszCurrentCode & szBoxNo, lBox)
this is the RecordDataLogger function where I enter this Data Logger number and if it has expired then I want to exit and I am exiting function and it doesn't get saved in the database as having been printed but the code still executes and the label still gets printed it is just missing some data which is incorrect, what I need to do is when data logger serial number has expired to stop printing all together.
so this is the RecordDataLogger Function
Public Function RecordDataLogger(Optional ByVal szNumber As String, Optional ByVal nBoxNo As Integer) As String
Dim szTemp As String
Dim nErr As Integer
Dim Handle As String
Dim szTemp1 As String
Dim szTemp2 As String
RecordDataLogger = ""
Handle = SessionHandle(cszSessionHandle)
If Handle < 0 Then
Call myObj.ReportError(Handle, Handle, "connecting to the required database.", App.title)
Exit Function
End If
'* Record the data recorder number and the fact labels were printed.
szTemp = InputBox("Enter Data Logger Serial No., or N/A if not applicable!", "Data Logger Serial Number", "")
nErr = myObj.DoQuery(Handle, "CHECKEXPIRY", BuildString(szTemp))
If myObj.ListCount(Handle) <> 0 Then
MsgBox "Data logger has expired! Printing will be cancelled, quarantine this data logger! ", vbCritical, App.title
Exit Function
If myObj.ReportError(Handle, nErr, "attempting to find a matching customer.", App.title) Then
End If
End If
szTemp1 = InputBox("Enter Data Logger Colour.", "Data Logger Colour", "")
szTemp2 = InputBox("Enter Issue Note Number.", "Issue Not Number", "")
'* Now store the new record indicating the label print...
nErr = myObj.DoQuery(Handle, "RECORDLABELS", GetItemData(lstSearchResults), _
BuildString(StandardDate(Now, , , True)), BuildString(szTemp), nBoxNo, BuildString(szNumber), BuildString(szTemp1), BuildString(szTemp2))
If myObj.ReportError(Handle, nErr, "attempting to record the Print record and the data recorder details.", App.title) Then
'* Do nothing ATM
End If
RecordDataLogger = szTemp
End Function
So then regadless if the data logger serial number has expired or not the code jumps to this line of code which is part of Private Sub cmdPrint_Click() and continues executing the code and the label gets printed.
So what I need to do is when I just to RecordLabelPrinter and datalogger has expired to stop the code from jumping and executing with the rest of the code and building the label.
This is that code
Select Case Val(GetConfiguration(Handle, "Print Mode"))
Case 0, 1
nOut = FreeFile
Open "C:\Printer.txt" For Output As #nOut
'*send to a text (generic) printer.
'Print #nOut, Chr(10)
'*"^XA" start ZPL II print sequence
Print #nOut, "${^XA}$"
'*"LH05,05"- Label Header at 05,05 dots
Print #nOut, "${^LH05,05}$"
'*print the sublocation
'Print #nOut, "^FO50,20^AD,28,16^FD" & subloco & "^FS"
'* If we have an address 2 then we need to move the address up a line.
If lblField(3).Caption <> "" Then
nOffset = 0
End If
'*label1(0)=abbreviation
Print #nOut, "${^FO80," & CStr(5 + nOffset) & "^AD,200,300^FD" & lblField(0).Caption & "^FS}$"
'*label1(1)=Hospital name
'Print #nOut, "${^FO100,720^AD,22,14^FD" & lblField(1).Caption & "^FS}$"
Print #nOut, "${^FO100," & CStr(185 + nOffset) & "^AD,22,14^FD" & lblField(1).Caption & "^FS}$"
'*label1(2)=address1 '*label1(3)=address 2 - should not be used
Print #nOut, "${^FO100," & CStr(205 + nOffset) & "^AD,22,14^FD" & lblField(2).Caption & "^FS}$"
'* If we have an address2 then print it...
If lblField(3).Caption <> "" Then
'*label1(3)=address 2 - should not be used
Print #nOut, "${^FO100,240^AD,22,14^FD" & lblField(3).Caption & "^FS}$"
End If
'*label1(4)=city/suburb
Print #nOut, "${^FO100,270^AD,22,14^FD" & lblField(4).Caption & "^FS}$"
'*label1(5)=state
Print #nOut, "${^FO100,295^AD,22,14^FD" & lblField(5).Caption & "^FS}$"
'*label1(6)=postcode
Print #nOut, "${^FO150,295^AD,22,14^FD" & lblField(6).Caption & "^FS}$"
'Print #nOut, "${^FO100,330^AD,22,14^FD" & "PH: " & lblField(7).Caption & "^FS}$"
'*box ID
Print #nOut, "${^FO250,455^AD,30,22^FD" & mszCurrentCode & szBoxNo & "^FS}$"
'*box of boxes
Print #nOut, "${^FO100,390^AD,22,14^FD" & szText & "^FS}$"
Print #nOut, "${^FO250,390^AD,22,14^FD" & mszCurrentCode & szBoxNo & "^FS}$"
Print #nOut, "${^FO250,695^AD,30,16^FD" & mszCurrentCode & szBoxNo & "^FS}$"
szDate = Format$(Now, "DD MMM YYYY HH:NN")
Print #nOut, "${^FO100,420^AD,18,14^FD" & szDate & "^FS}$"
Print #nOut, "${^FO480,390^AD,18,14^FD" & szLoggerCode & "^FS}$"
'********Print #nOut, "^FO10,450^AD,18,14^FDBox........ OF .......Boxes^FD" '" & boxtext & "^FS"
'*Date
'*******Print #nOut, "^FO10,475^AD,21,14^FD" & Format(Now(), "dd-mm-yyyy") & "^FS"
'*bar code as code 128 subset A
Print #nOut, "${^FO250,490^BCN,200,N,N,N^FD" & mszCurrentCode & szBoxNo & "^FS}$"
'*eye readable
'Print #nOut, "${^FO250,655^AD,30,16^FD" & mszCurrentCode & szBoxNo & "^FS}$"
'*repeat details in POd section
'Print #nOut, "^FO100,700^AD,22,14^FD" & subloco & "^FS"
Print #nOut, "${^FO10,750^AD,44,16^FD" & lblField(1).Caption & "^FS}$"
Print #nOut, "${^FO10,790^AD,44,16^FD" & lblField(2).Caption & "^FS}$"
Print #nOut, "${^FO10,840^AD,44,16^FD" & lblField(3).Caption & "^FS}$"
Print #nOut, "${^FO10,890^AD,44,16^FD" & lblField(4).Caption & "^FS}$"
Print #nOut, "${^FO10,940^AD,28,14^FD" & "PH: " & lblField(7).Caption & "^FS}$"
Print #nOut, "${^FO450,900^AD,44,16^FD" & lblField(5).Caption & " " & lblField(6).Caption & "^FS}$"
Print #nOut, "${^FO220,980^AD,22,14^FD" & szText & "^FS}$"
Print #nOut, "${^FO590,980^AD,18,14^FD" & szLoggerCode & "^FS}$"
Print #nOut, "${^FO360,980^AD,18,14^FD" & mszCurrentCode & szBoxNo & "^FS}$"
Print #nOut, "${^FO220,960^AD,18,14^FD" & szDate & "^FS}$"
Print #nOut, "${^F0280,1000^AD,18,14^FD" & szTemp2 & "^FS}$"
'Print #nOut, "${^F0600,030^AD,18,14^FDDispatch Date: " & "^FS}$"
Print #nOut, "${^FO40,1030^AD,18,14^FDInitials: Dispatch Time: Pack Type:" & "^FS}$"
'*from details,ARCBS address and details
Print #nOut, "${^FO40,1050^AD,22,14^FDFrom: " & lblRCBB(0).Caption & "^FS}$"
Print #nOut, "${^FO120,1070^AD,22,14^FD" & lblRCBB(1).Caption & "^FS}$"
Print #nOut, "${^FO120,1090^AD,22,14^FD" & lblRCBB(2).Caption & "^FS}$"
Print #nOut, "${^FO120,1110^AD,22,14^FDPhone: " & lblRCBB(3).Caption & " fax: " & lblRCBB(4).Caption & "^FS}$"
'* Temperature logger included
If szLoggerCode <> "" Then
Print #nOut, "${" & GetConfiguration(Handle, "Logger Text Prefix") & "Temperature Logger Included. " & szLoggerCode & "^FS}$"
End If
'*
Print #nOut, "${^XZ}$"
Close #nOut
I know this is long and complicated I hope somebody will have the patience to go through it and help me as I am not sure how to do it.
So I need something after this
szLoggerCode = RecordDataLogger(mszCurrentCode & szBoxNo, lBox)
but before this first line of code
Select Case Val(GetConfiguration(Handle, "Print Mode"))
Case 0, 1
nOut = FreeFile
Open "C:\Printer.txt" For Output As #nOut
that will recognize that data logger has expired and cancel printing alltogether
Thanks a lot guys
So I click on "Print label" and then this code takes me to RecordLabelPrinter function where I enter and query data
If txtNbrBoxes.Text = "" Then
szText = "one box"
Else
szText = "Box " & CStr(lBox) & " of " & txtNbrBoxes.Text
End If
szLoggerCode = RecordDataLogger(mszCurrentCode & szBoxNo, lBox)
this is the RecordDataLogger function where I enter this Data Logger number and if it has expired then I want to exit and I am exiting function and it doesn't get saved in the database as having been printed but the code still executes and the label still gets printed it is just missing some data which is incorrect, what I need to do is when data logger serial number has expired to stop printing all together.
so this is the RecordDataLogger Function
Public Function RecordDataLogger(Optional ByVal szNumber As String, Optional ByVal nBoxNo As Integer) As String
Dim szTemp As String
Dim nErr As Integer
Dim Handle As String
Dim szTemp1 As String
Dim szTemp2 As String
RecordDataLogger = ""
Handle = SessionHandle(cszSessionHandle)
If Handle < 0 Then
Call myObj.ReportError(Handle, Handle, "connecting to the required database.", App.title)
Exit Function
End If
'* Record the data recorder number and the fact labels were printed.
szTemp = InputBox("Enter Data Logger Serial No., or N/A if not applicable!", "Data Logger Serial Number", "")
nErr = myObj.DoQuery(Handle, "CHECKEXPIRY", BuildString(szTemp))
If myObj.ListCount(Handle) <> 0 Then
MsgBox "Data logger has expired! Printing will be cancelled, quarantine this data logger! ", vbCritical, App.title
Exit Function
If myObj.ReportError(Handle, nErr, "attempting to find a matching customer.", App.title) Then
End If
End If
szTemp1 = InputBox("Enter Data Logger Colour.", "Data Logger Colour", "")
szTemp2 = InputBox("Enter Issue Note Number.", "Issue Not Number", "")
'* Now store the new record indicating the label print...
nErr = myObj.DoQuery(Handle, "RECORDLABELS", GetItemData(lstSearchResults), _
BuildString(StandardDate(Now, , , True)), BuildString(szTemp), nBoxNo, BuildString(szNumber), BuildString(szTemp1), BuildString(szTemp2))
If myObj.ReportError(Handle, nErr, "attempting to record the Print record and the data recorder details.", App.title) Then
'* Do nothing ATM
End If
RecordDataLogger = szTemp
End Function
So then regadless if the data logger serial number has expired or not the code jumps to this line of code which is part of Private Sub cmdPrint_Click() and continues executing the code and the label gets printed.
So what I need to do is when I just to RecordLabelPrinter and datalogger has expired to stop the code from jumping and executing with the rest of the code and building the label.
This is that code
Select Case Val(GetConfiguration(Handle, "Print Mode"))
Case 0, 1
nOut = FreeFile
Open "C:\Printer.txt" For Output As #nOut
'*send to a text (generic) printer.
'Print #nOut, Chr(10)
'*"^XA" start ZPL II print sequence
Print #nOut, "${^XA}$"
'*"LH05,05"- Label Header at 05,05 dots
Print #nOut, "${^LH05,05}$"
'*print the sublocation
'Print #nOut, "^FO50,20^AD,28,16^FD" & subloco & "^FS"
'* If we have an address 2 then we need to move the address up a line.
If lblField(3).Caption <> "" Then
nOffset = 0
End If
'*label1(0)=abbreviation
Print #nOut, "${^FO80," & CStr(5 + nOffset) & "^AD,200,300^FD" & lblField(0).Caption & "^FS}$"
'*label1(1)=Hospital name
'Print #nOut, "${^FO100,720^AD,22,14^FD" & lblField(1).Caption & "^FS}$"
Print #nOut, "${^FO100," & CStr(185 + nOffset) & "^AD,22,14^FD" & lblField(1).Caption & "^FS}$"
'*label1(2)=address1 '*label1(3)=address 2 - should not be used
Print #nOut, "${^FO100," & CStr(205 + nOffset) & "^AD,22,14^FD" & lblField(2).Caption & "^FS}$"
'* If we have an address2 then print it...
If lblField(3).Caption <> "" Then
'*label1(3)=address 2 - should not be used
Print #nOut, "${^FO100,240^AD,22,14^FD" & lblField(3).Caption & "^FS}$"
End If
'*label1(4)=city/suburb
Print #nOut, "${^FO100,270^AD,22,14^FD" & lblField(4).Caption & "^FS}$"
'*label1(5)=state
Print #nOut, "${^FO100,295^AD,22,14^FD" & lblField(5).Caption & "^FS}$"
'*label1(6)=postcode
Print #nOut, "${^FO150,295^AD,22,14^FD" & lblField(6).Caption & "^FS}$"
'Print #nOut, "${^FO100,330^AD,22,14^FD" & "PH: " & lblField(7).Caption & "^FS}$"
'*box ID
Print #nOut, "${^FO250,455^AD,30,22^FD" & mszCurrentCode & szBoxNo & "^FS}$"
'*box of boxes
Print #nOut, "${^FO100,390^AD,22,14^FD" & szText & "^FS}$"
Print #nOut, "${^FO250,390^AD,22,14^FD" & mszCurrentCode & szBoxNo & "^FS}$"
Print #nOut, "${^FO250,695^AD,30,16^FD" & mszCurrentCode & szBoxNo & "^FS}$"
szDate = Format$(Now, "DD MMM YYYY HH:NN")
Print #nOut, "${^FO100,420^AD,18,14^FD" & szDate & "^FS}$"
Print #nOut, "${^FO480,390^AD,18,14^FD" & szLoggerCode & "^FS}$"
'********Print #nOut, "^FO10,450^AD,18,14^FDBox........ OF .......Boxes^FD" '" & boxtext & "^FS"
'*Date
'*******Print #nOut, "^FO10,475^AD,21,14^FD" & Format(Now(), "dd-mm-yyyy") & "^FS"
'*bar code as code 128 subset A
Print #nOut, "${^FO250,490^BCN,200,N,N,N^FD" & mszCurrentCode & szBoxNo & "^FS}$"
'*eye readable
'Print #nOut, "${^FO250,655^AD,30,16^FD" & mszCurrentCode & szBoxNo & "^FS}$"
'*repeat details in POd section
'Print #nOut, "^FO100,700^AD,22,14^FD" & subloco & "^FS"
Print #nOut, "${^FO10,750^AD,44,16^FD" & lblField(1).Caption & "^FS}$"
Print #nOut, "${^FO10,790^AD,44,16^FD" & lblField(2).Caption & "^FS}$"
Print #nOut, "${^FO10,840^AD,44,16^FD" & lblField(3).Caption & "^FS}$"
Print #nOut, "${^FO10,890^AD,44,16^FD" & lblField(4).Caption & "^FS}$"
Print #nOut, "${^FO10,940^AD,28,14^FD" & "PH: " & lblField(7).Caption & "^FS}$"
Print #nOut, "${^FO450,900^AD,44,16^FD" & lblField(5).Caption & " " & lblField(6).Caption & "^FS}$"
Print #nOut, "${^FO220,980^AD,22,14^FD" & szText & "^FS}$"
Print #nOut, "${^FO590,980^AD,18,14^FD" & szLoggerCode & "^FS}$"
Print #nOut, "${^FO360,980^AD,18,14^FD" & mszCurrentCode & szBoxNo & "^FS}$"
Print #nOut, "${^FO220,960^AD,18,14^FD" & szDate & "^FS}$"
Print #nOut, "${^F0280,1000^AD,18,14^FD" & szTemp2 & "^FS}$"
'Print #nOut, "${^F0600,030^AD,18,14^FDDispatch Date: " & "^FS}$"
Print #nOut, "${^FO40,1030^AD,18,14^FDInitials: Dispatch Time: Pack Type:" & "^FS}$"
'*from details,ARCBS address and details
Print #nOut, "${^FO40,1050^AD,22,14^FDFrom: " & lblRCBB(0).Caption & "^FS}$"
Print #nOut, "${^FO120,1070^AD,22,14^FD" & lblRCBB(1).Caption & "^FS}$"
Print #nOut, "${^FO120,1090^AD,22,14^FD" & lblRCBB(2).Caption & "^FS}$"
Print #nOut, "${^FO120,1110^AD,22,14^FDPhone: " & lblRCBB(3).Caption & " fax: " & lblRCBB(4).Caption & "^FS}$"
'* Temperature logger included
If szLoggerCode <> "" Then
Print #nOut, "${" & GetConfiguration(Handle, "Logger Text Prefix") & "Temperature Logger Included. " & szLoggerCode & "^FS}$"
End If
'*
Print #nOut, "${^XZ}$"
Close #nOut
I know this is long and complicated I hope somebody will have the patience to go through it and help me as I am not sure how to do it.
So I need something after this
szLoggerCode = RecordDataLogger(mszCurrentCode & szBoxNo, lBox)
but before this first line of code
Select Case Val(GetConfiguration(Handle, "Print Mode"))
Case 0, 1
nOut = FreeFile
Open "C:\Printer.txt" For Output As #nOut
that will recognize that data logger has expired and cancel printing alltogether
Thanks a lot guys