T
tkosel
I hope this isn't too long winded!
I have a simple little form with 4 controls on it. Three of the controls
have Got Focus Events as illustrated below.
A scanner is attached to Com2 which is being controlled(?) by a MSComm
active X control.(Named "NewMatCom) Tab order is PartNumber, LotNumber,
ClockNumber, NextControl
When I scan, PartNumber gets populated, focus moves to next control,
LotNumber.
I scan again, LotNumber gets populated, focus moves to the next control,
ClockNumber
I scan again, ClockNumber get populated, however now Access gives a run time
error '2110' and says it can't move the
focus to the control ClockNumber. When I debug, it is breaking on the
'Me.ClockNumber.SetFocus' statement in the LotNumber
procedure. When I step through that, it says it can't move the focus to the
LotNumber control. When I debug that, it is
breaking on the 'Me.LotNumber.SetFocus' statement in the PartNumber
procedure. When I step through that, it finishes but
locks up. Control Break Takes me back to the form, the fields are all filled
in, the focus is on the lot number field.
The scanned input string is ended by a Carriage Return. (Programmed into the
Scanner as "Enter" key.)
Any ideas on what is wrong?
=====================================================
Private Sub PartNumber_GotFocus()
Dim V_IncomingDataStream
If Me.NewMatCom.PortOpen = False Then 'Open the port
Me.NewMatCom.PortOpen = True
End If
Do
If Me.NewMatCom.PortOpen = False Then
Exit Do
End If
V_IncomingDataStream = V_IncomingDataStream &_
Me.NewMatCom.Input 'Read the data
Loop Until InStr(V_IncomingDataStream, vbCr) 'Decide if it is complete
If Me.NewMatCom.PortOpen = True Then 'Close the port
Me.NewMatCom.PortOpen = False
End If
Me.PartNumber.Locked = False
Me.PartNumber = V_IncomingDataStream
Me.PartNumber.Locked = True
Me.Repaint
Done:
Me.LotNumber.SetFocus
End Sub
=====================================================
Private Sub LotNumber_GotFocus()
Dim V_IncomingDataStream
If Me.NewMatCom.PortOpen = False Then 'Open the port
Me.NewMatCom.PortOpen = True
End If
Do
If Me.NewMatCom.PortOpen = False Then
Exit Do
End If
V_IncomingDataStream = V_IncomingDataStream &_
Me.NewMatCom.Input 'Read the data
Loop Until InStr(V_IncomingDataStream, vbCr) 'Decide if it is complete
If Me.NewMatCom.PortOpen = True Then 'Close the port
Me.NewMatCom.PortOpen = False
End If
Me.LotNumber.Locked = False
Me.LotNumber = V_IncomingDataStream
Me.LotNumber.Locked = True
Done:
Me.ClockNumber.SetFocus
End Sub
====================================================
Private Sub ClockNumber_GotFocus()
Dim V_IncomingDataStream
If Me.NewMatCom.PortOpen = False Then 'Open the port
Me.NewMatCom.PortOpen = True
End If
Do
If Me.NewMatCom.PortOpen = False Then
Exit Do
End If
V_IncomingDataStream = V_IncomingDataStream &_
Me.NewMatCom.Input 'Read the data
Loop Until InStr(V_IncomingDataStream, vbCr) 'Decide if it is complete
If Me.NewMatCom.PortOpen = True Then 'Close the port
Me.NewMatCom.PortOpen = False
End If
Me.ClockNumber.Locked = False
Me.ClockNumber = V_IncomingDataStream
Me.ClockNumber.Locked = True
Done:
Me.NextControl.SetFocus
End Sub
I have a simple little form with 4 controls on it. Three of the controls
have Got Focus Events as illustrated below.
A scanner is attached to Com2 which is being controlled(?) by a MSComm
active X control.(Named "NewMatCom) Tab order is PartNumber, LotNumber,
ClockNumber, NextControl
When I scan, PartNumber gets populated, focus moves to next control,
LotNumber.
I scan again, LotNumber gets populated, focus moves to the next control,
ClockNumber
I scan again, ClockNumber get populated, however now Access gives a run time
error '2110' and says it can't move the
focus to the control ClockNumber. When I debug, it is breaking on the
'Me.ClockNumber.SetFocus' statement in the LotNumber
procedure. When I step through that, it says it can't move the focus to the
LotNumber control. When I debug that, it is
breaking on the 'Me.LotNumber.SetFocus' statement in the PartNumber
procedure. When I step through that, it finishes but
locks up. Control Break Takes me back to the form, the fields are all filled
in, the focus is on the lot number field.
The scanned input string is ended by a Carriage Return. (Programmed into the
Scanner as "Enter" key.)
Any ideas on what is wrong?
=====================================================
Private Sub PartNumber_GotFocus()
Dim V_IncomingDataStream
If Me.NewMatCom.PortOpen = False Then 'Open the port
Me.NewMatCom.PortOpen = True
End If
Do
If Me.NewMatCom.PortOpen = False Then
Exit Do
End If
V_IncomingDataStream = V_IncomingDataStream &_
Me.NewMatCom.Input 'Read the data
Loop Until InStr(V_IncomingDataStream, vbCr) 'Decide if it is complete
If Me.NewMatCom.PortOpen = True Then 'Close the port
Me.NewMatCom.PortOpen = False
End If
Me.PartNumber.Locked = False
Me.PartNumber = V_IncomingDataStream
Me.PartNumber.Locked = True
Me.Repaint
Done:
Me.LotNumber.SetFocus
End Sub
=====================================================
Private Sub LotNumber_GotFocus()
Dim V_IncomingDataStream
If Me.NewMatCom.PortOpen = False Then 'Open the port
Me.NewMatCom.PortOpen = True
End If
Do
If Me.NewMatCom.PortOpen = False Then
Exit Do
End If
V_IncomingDataStream = V_IncomingDataStream &_
Me.NewMatCom.Input 'Read the data
Loop Until InStr(V_IncomingDataStream, vbCr) 'Decide if it is complete
If Me.NewMatCom.PortOpen = True Then 'Close the port
Me.NewMatCom.PortOpen = False
End If
Me.LotNumber.Locked = False
Me.LotNumber = V_IncomingDataStream
Me.LotNumber.Locked = True
Done:
Me.ClockNumber.SetFocus
End Sub
====================================================
Private Sub ClockNumber_GotFocus()
Dim V_IncomingDataStream
If Me.NewMatCom.PortOpen = False Then 'Open the port
Me.NewMatCom.PortOpen = True
End If
Do
If Me.NewMatCom.PortOpen = False Then
Exit Do
End If
V_IncomingDataStream = V_IncomingDataStream &_
Me.NewMatCom.Input 'Read the data
Loop Until InStr(V_IncomingDataStream, vbCr) 'Decide if it is complete
If Me.NewMatCom.PortOpen = True Then 'Close the port
Me.NewMatCom.PortOpen = False
End If
Me.ClockNumber.Locked = False
Me.ClockNumber = V_IncomingDataStream
Me.ClockNumber.Locked = True
Done:
Me.NextControl.SetFocus
End Sub