Printing to COM1 (1 Viewer)

ian_w

Registered User.
Local time
Today, 06:35
Joined
Jun 13, 2006
Messages
64
We have a stock control database that uses barcode printers attached to COM1. We have recently upgraded the PC's to new XP machines and now the barcode printers wont work as XP doesnt allow access sufficient access.

I am trying to write a small module using MSComm that will let me print out to COM1, as I have pretty much zero programming experience this is proving to be tricky...

This is my code so far

Private Sub Command1_Click()
Dim Instring As String
MSComm1.CommPort = 1
MSComm1.Settings = "9600,N,8,1"
MSComm1.rtsenable = True
MSComm1.PortOpen = True
MSComm1.Output = "NTLCODE"
MSComm1.Output = Text1.Text
MSComm1.PortOpen = False
End Sub

NTLCODE is a small .BAS file which is sent to the printer and tells it how to position the data on the label, I am trying to get the printer to printout the text from text box 1...

When I click the command button nothing happens????

Anyone have any clues as to my problem....
 

RuralGuy

AWF VIP
Local time
Yesterday, 23:35
Joined
Jul 2, 2005
Messages
13,826
WinXP will allow you to define a printer on a Com port. Is that not good enough?
 

ian_w

Registered User.
Local time
Today, 06:35
Joined
Jun 13, 2006
Messages
64
XP wont allow users in Access 97 direct access to the hardware to print to COM1 , to be honest its an absolute nightmate situation.

If anyone has any suggestions they would be very much appreciated....

Ive tried granting the users admin rights etc, nothing seems to work :(
 

allan57

Allan
Local time
Today, 06:35
Joined
Nov 29, 2004
Messages
336
You need to send one character at a time through the COMM port, create a function that will loop through the characters your are sending.

Below is an example of how I tend to send data to an output device:

Private Sub Example_Click()

MSComm1.PortOpen = True

LoopCOMM ("?02&11,112,5,15,40,14,1;" & strBarcodeData)
LoopCOMM (Chr(13))
LoopCOMM ("?02&10,112,45,0,1,34,8,1;" & CStr(rstBarcodeData!lngQS_Job_Number))
LoopCOMM (Chr(13))
LoopCOMM ("?02&10,112,79,0,1,34,14,1;" & RTrim(rstBarcodeData!txtBatch_Roll_Number)) & " " & strSample_Type
LoopCOMM (Chr(13))
LoopCOMM ("?02&10,112,114,0,1,34,12,1;" & rstBarcodeData!txtStrip_Label_Text1)
LoopCOMM (Chr(13))
LoopCOMM ("?01&")
LoopCOMM (Chr(13))

MSComm1.PortOpen = False

End sub

Public Function LoopCOMM(strPassData As String)

Dim intCounter As Integer

For intCounter = 1 To Len(strPassData)

MSComm1.Output = MID(strPassData, intCounter, 1)

Next intCounter

End Function
 

ian_w

Registered User.
Local time
Today, 06:35
Joined
Jun 13, 2006
Messages
64
Thanks for the help,

Now seems though that it may be a more basic rights issue...

When I am logged on locally to the PC (as a standard user with a local user accoun) I can print to the COM port no problem, when I log on with a domain account with Group Policies etc it fails due to a file access error.

Back to the drawing board I suppose
 

Users who are viewing this thread

Top Bottom