View Full Version : Very Basic MSComm Problem


ian_w
02-11-2008, 04:22 AM
Hi,

Im trying to get to grips with VBA in Access 97, im currently trying to write a small MSComm module that we can bolt on to various db's in house.

The last time I touched access was well over 12 months ago and that was a very basic bit of code so im going into this blind.

At the minute all I am trying to do is scan a serial number with a serial scanner and then print the barcode in a text box, I can't get it to work though and im sure its something simple I am missing.

So far I have the following

Setting the scanner

Public Sub Scanner_Settings()

With Me.MSComm1
'Use COM Port 1
.CommPort = 1
'Sets and returns the hardware handshaking protocol. Data is transferred from the hardware port to the receive buffer
.Handshaking = comXOnXoff
'9600 baud, no parity, 8 data, and 1 stop bit.
.Settings = "9600,N,8,1"
'Sets and returns the number of characters the Input property reads from the receive buffer.
.InputLen = 30000
'Sets the type of data retrieved by the Input property.
.InputMode = comInputModeText


End With

Me.MSComm1.PortOpen = True
End Sub

Displaying a scanned barcode.

Private Sub MSComm1_OnComm()
Dim Barcode As String

MSComm1.Input = Barcode
Me.Text1.SetFocus
Me.Text1.Value = Barcode

End Sub

I've looked all over the net for a example of what im after but I can't find anything, what am I missing?

RuralGuy
02-11-2008, 06:50 AM
So your Barcode reader comes in through a serial port rather than in parallel with the keyboard?

ian_w
02-11-2008, 06:52 AM
So your Barcode reader comes in through a serial port rather than in parallel with the keyboard?

Yes, barcode reader is on an RS232 serial port.

RuralGuy
02-11-2008, 07:05 AM
I have not used MSComm but you may want to try:
Private Sub MSComm1_OnComm()

Me.Text1 = MSComm1.Input

End Sub

ian_w
02-11-2008, 07:08 AM
I have not used MSComm but you may want to try:
Private Sub MSComm1_OnComm()

Me.Text1 = MSComm1.Input

End Sub

Hi, Thanks for the reply, what you suggest above i have already tried with no luck.

RuralGuy
02-11-2008, 07:31 AM
Maybe this link will help: PRB: Can't Receive Data When Using MSCOMM.OCX Control (http://support.microsoft.com/kb/141071/en-us)

ian_w
02-12-2008, 02:13 AM
Thanks for the link, I added the line of code but sadly it had no effect.

Its annoying as im sure its something simple that im missing :o

RuralGuy
02-12-2008, 05:12 AM
How about this link:
Receiving Data Using the MSComm Control's OnComm Event (http://support.microsoft.com/kb/194922/en-us)
or maybe this one:
Troubleshooting Tips for the MSComm Control (http://support.microsoft.com/kb/192012/en-us)

wh00t
02-12-2008, 05:35 AM
try setting these 2 values

MSComm1.RThreshold = 1
MSComm1.SThreshold = 1

ian_w
02-13-2008, 01:44 AM
I figured this out, my problem was that I was not calling the Scanner_Settings module so the MSComm control was never activated.

Once I moved my Scanner settings into Form_Load it worked just as I wanted it to.

Ian

RuralGuy
02-13-2008, 03:39 AM
Excellent! Glad you got it sorted.