I am developing an Access 2007 "project" (.adp) as a front-end to a SQL Server 2005 Express database.
Earlier today I managed to download and register MSCOMM32.OCX and now appear to be able to add an MSCOMM control to an Access Form.
However, I have not been able to see any input coming in from a barcode scanner attached to my COM1: serial port. When I move over to an old DOS application on the same laptop, the scanner input arrives OK, so I am fairly certain that communication with the computer is OK.
I have attached the code I am using to initialise the MSComm0 control in my "Form_Load" procedure and it reports "No error".
I have also attached what I do in my "MSComm0_OnComm" procedure and although I have many "tracer" MsgBox messages in there, I have only once had one displayed.
After "reading" the MSComm0 input buffer, how is that buffer "emptied"?
Also, in my Form's "Design View", the MSComm0 control's properties do not list many items under the "Events" tab but all the items I have seen on the internet mention the "OnComm" event, which I have produced a VBA procedure for.
Can anyone suggest how I check that MSCOMM is acrually "working" for me and can anyone explain why I don't seem to be getting any data coming through?
Private Sub Form_Load()
.CommPort = 1
.Break = False
.DTREnable = True
.EOFEnable = False
.Handshaking = comNone
.InBufferCount = 0
.InBufferSize = 1024
.InputLen = 1024
.InputMode = comInputModeText
.NullDiscard = False
.OutBufferCount = 0
.OutBufferSize = 1024
.ParityReplace = Chr(0)
.RThreshold = 1
.SThreshold = 0
.Settings = "9600,N,8,1"
.MSComm0.PortOpen = True
If Err.Number = 0 Then
MsgBox "No error after establishing COM port"
MsgBox "PROBLEM - error after establishing COM port"
End Sub ' Form_Load
Private Sub MSComm0_OnComm()
Dim strInputString As String
Dim strChar As String
MsgBox "We are in MSComm0_OnComm"
If .CommEvent = comEvReceive Then
strInputString = ""
While .InBufferCount > 0
strChar = .Input
MsgBox "Barcod input char : " & strChar
If strChar = Chr$(13) Then
If Not genAllBlanks(Nz(strInputString, "")) Then
.cmbStockCode = strInputString
MsgBox "Barcode input string : " & strInputString
strInputString = ""
strInputString = strInputString & strChar
End Sub ' MSComm0_OnComm