Very Basic MSComm Problem

ian_w

Registered User.
Local time
Today, 20:18
Joined
Jun 13, 2006
Messages
64
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

Code:
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.

Code:
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?
 
So your Barcode reader comes in through a serial port rather than in parallel with the keyboard?
 
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.
 
I have not used MSComm but you may want to try:
Code:
Private Sub MSComm1_OnComm()

    Me.Text1 = MSComm1.Input 
        
End Sub
 
I have not used MSComm but you may want to try:
Code:
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.
 
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
 
try setting these 2 values
Code:
MSComm1.RThreshold = 1
MSComm1.SThreshold = 1
 
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
 

Users who are viewing this thread

Back
Top Bottom