Serial Port Printing in VBA

tbca-mps
NewLounger
Posts: 1
Joined: 07 Jun 2011, 19:25

Serial Port Printing in VBA

Post by tbca-mps »

I have built a small application in Access and VBA that acts as a SATO label printer. When I first turn the program on, I get an error:

FRAMING ERROR

I then have to power cycle the printer, and run a program called SeeIt.exe (third party program for raw printing). This program shows if the printer is online. To me, it looks like it polls the serial port to open the connection first. I can then open Access, and printing runs as required.

How can I get VBA to open this first so that my users can just start printing.

Thanks in advance.

Here is the code that executes in VB when the button is pushed.

Code: Select all

Private Sub cmdCreateCarpet_Click()
Dim num As Integer
 
Dim db As Database
Dim rs As DAO.Recordset
Dim qdf As QueryDef
Dim lblprnt As String

Set db = CurrentDb
Set qdf = db.QueryDefs("qryCarpetLabel")
Set rs = qdf.OpenRecordset()

num = 0
Do
num = num + 1
    DoCmd.RunCommand acCmdSaveRecord
    seq = seq + 1
    If seq = 10000 Then
    seq = 1
    End If
  Open "Com1:57600,n,8,1" For Output As #1
  Print #1, "AV30H15FW0303V550H570V240H15FW03H570V390H15FW03H570V30H340FW03V360V75H50P5$A,150,120,0$=" & inhouse & "V240H20$A,40,25,0$=DateV240H345$A,40,25,0$=ShiftV35H20$A,40,25,0$=InHouseV35H345$A,40,25,0$=SequenceV98H360P5$A,100,75,0$=" & Format(seq, "0000") & "V280H50P5$A,100,75,0$=" & Format(prntdate, "yymmdd") & "V280H425P5$A,100,75,0$=" & shift & "V450H60BG02070>G" & kanban & "V530H85L0101XM   " & kanban & "Q01Z"

 Close #1

Loop Until num = txtCopies


End Sub

User avatar
Charlotte
Her Majesty
Posts: 499
Joined: 19 Jan 2010, 07:13

Re: Serial Port Printing in VBA

Post by Charlotte »

Are you asking how to power cycle your printer and run SeeIt from VBA code? Do you have an API for SeeIt? Do you have the printer codes for your printer? Otherwise, not.
Charlotte