Looping Problem

T

tkosel

To all,

I have a problem that I could use some help on. I have a form that contains
two text boxes that I want to fill with data from either the keyboard (user
types in) or from a scale via serial cable using mscomm control. I can do
one or the other, but not both. My code for the data field (ON ENTER event)
appears below. (I realize that I am very "wordy".)

Dim V_IncomingDataStream
Me.DataMessage.Visible = True
Me.Repaint

If Me.NewMatCom.PortOpen = False Then 'Open the port
Me.NewMatCom.PortOpen = True
End If

If Me.DisableScale = False Then
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

Me.WEIGHT = V_IncomingDataStream
End If

If Me.NewMatCom.PortOpen = True Then
Me.NewMatCom.PortOpen = False
Me.DataMessage.Visible = False
End If

This works good when the data comes from the serial device. The problem is
that when this event occurrs, I get in a loop that waits for the vbCR , input
from the device before I can move on. It locks up Access if I don't input
data from the serial device! (I have a check box that the user can elect to
turn on or off to determine where the data will be input from ahead of time,
but if they forget and click somewhere else on the form before they send data
from the serial device, it also locks up. ) I must be stupid, but cannot
think of a way out of it. Any ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top