fasse
asked on
Mscomm in access 2007
Back in access 2000 had wrote a database for a collecting live data from a scale. Now I need to collect date and have it run process when someone scans a barcode. I have a rs232 barcode scanner but I don't know how to program this new mscomm control. here is my code so far.
With mscomm1
.CommPort = 1
.Handshaking = 2 - comRTS
.RThreshold = 1
.RTSEnable = True
.Settings = "9600,n,8,1"
.SThreshold = 1
If .PortOpen = True Then
.PortOpen = False
End If
.PortOpen = True
mscomm1.Output = Me.test
End With
When I open the form it says the port is open already so I thought i could check if it was open and close it so it would be opened when I wanted it to. Also I need the oncomm event so the scanner triggers printing things out.
Andy help would be great thanks.
With mscomm1
.CommPort = 1
.Handshaking = 2 - comRTS
.RThreshold = 1
.RTSEnable = True
.Settings = "9600,n,8,1"
.SThreshold = 1
If .PortOpen = True Then
.PortOpen = False
End If
.PortOpen = True
mscomm1.Output = Me.test
End With
When I open the form it says the port is open already so I thought i could check if it was open and close it so it would be opened when I wanted it to. Also I need the oncomm event so the scanner triggers printing things out.
Andy help would be great thanks.
ASKER
It is a Honeywell Voyager 9500 232
I called them and they said they have not sample code so I have been trying to piece this together.
Here is the code I have so far.
Private Sub Form_Load()
With NETComm0
.CommPort = 1
.Handshaking = 2 - comRTS
.RThreshold = 1
.RTSEnable = True
.Settings = "9600,n,8,1"
.SThreshold = 1
If .PortOpen = True Then
.PortOpen = False
Else
End If
End With
Me.test = "worked"
End Sub
Private Sub netComm0_OnComm()
Dim something As String
something = NETComm0.InputData
End Sub
Private Sub Form_Unload(Cancel As Integer)
If NETComm0.PortOpen = True Then
NETComm0.PortOpen = False
Else
End If
End Sub
I called them and they said they have not sample code so I have been trying to piece this together.
Here is the code I have so far.
Private Sub Form_Load()
With NETComm0
.CommPort = 1
.Handshaking = 2 - comRTS
.RThreshold = 1
.RTSEnable = True
.Settings = "9600,n,8,1"
.SThreshold = 1
If .PortOpen = True Then
.PortOpen = False
Else
End If
End With
Me.test = "worked"
End Sub
Private Sub netComm0_OnComm()
Dim something As String
something = NETComm0.InputData
End Sub
Private Sub Form_Unload(Cancel As Integer)
If NETComm0.PortOpen = True Then
NETComm0.PortOpen = False
Else
End If
End Sub
This should be helpfull:
INFO: Receiving Data Using the MSComm Control's OnComm Event
http://support.microsoft.com/kb/194922
If you look at the article, you'll see your most of the way there already. The code for the OnComm event should drop right in from the article.
Let me know where that gets you...
Jim.
INFO: Receiving Data Using the MSComm Control's OnComm Event
http://support.microsoft.com/kb/194922
If you look at the article, you'll see your most of the way there already. The code for the OnComm event should drop right in from the article.
Let me know where that gets you...
Jim.
ASKER
I will give it a try.
ASKER
I have it working except for 2 problems. The code will return nothing to the test text box I have on the form unless I have the code stopping at end sub. If I do that and keep hitting the stop button to reset the code I get an output on the form.
2nd is the barcode scanner does not read the same amount every time. One time it may ready a sting length of 3 next time it may ready 30. I thought if I closed the port then opened it and cleared the buffer it would fix the buffer problem but did not help. My string should be something like this F569375.0 but I will get (.0 F569375.0 F569375.0 F569375) with little squares in the spaces
Also I find that it is storing the read then sending it to the computer on the next time. so i have the code stop and scan a couple of barcodes it will not send those until i reset the code and read another code. Problem with that is that is does not send the one it just read it send the other two it read before. It is like it is not sending real time scans.
I am at a lose.
Private Sub netComm0_OnComm()
Dim InBuff As String
Dim fixed As String
Me.test = ""
InBuff = NETComm0.InputData
fixed = InBuff
Me.test = "" ''used this to clear text box to verify inputdata
Me.test = fixed
NETComm0.PortOpen = False
NETComm0.PortOpen = True
NETComm0.InBufferCount = 0
NETComm0.OutBufferCount = 0
End Sub
2nd is the barcode scanner does not read the same amount every time. One time it may ready a sting length of 3 next time it may ready 30. I thought if I closed the port then opened it and cleared the buffer it would fix the buffer problem but did not help. My string should be something like this F569375.0 but I will get (.0 F569375.0 F569375.0 F569375) with little squares in the spaces
Also I find that it is storing the read then sending it to the computer on the next time. so i have the code stop and scan a couple of barcodes it will not send those until i reset the code and read another code. Problem with that is that is does not send the one it just read it send the other two it read before. It is like it is not sending real time scans.
I am at a lose.
Private Sub netComm0_OnComm()
Dim InBuff As String
Dim fixed As String
Me.test = ""
InBuff = NETComm0.InputData
fixed = InBuff
Me.test = "" ''used this to clear text box to verify inputdata
Me.test = fixed
NETComm0.PortOpen = False
NETComm0.PortOpen = True
NETComm0.InBufferCount = 0
NETComm0.OutBufferCount = 0
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I didn't get it figured out but the project moved in a different direction. I appreciated the help.
Check the scanner Mfg's web site. They often have VB 6.0 or VBA examples. Very often you can almost drop code right in.
Also, even rs232 scanners often come with a driver and you talk to the driver rather then talking directly to port. Most newer scanners are this way, especially if they are USB based.
If you need more, post the scanner model and mfg.
Jim.