I am having some problems with my code and could use some insight. I am waiting for a field in a one-record file to be filled by an outside process. Once this field is filled, I can retrieve the value and continue processing. There are 2 sides on the screen and this code is operating on the right side. Both sides have a 'Close' button that can be used to close out one side or the other. If the user clicks the close button on the side that is waiting for the field to be filled, he is able to do other operations, but sometimes I get an error when the Do loop attempts to check the screen field for a value (when the user closes the side of the form, this field is made invisible, hence the error)
Is there some way to make this loop end when the close button is selected??
Here is the code:
'begin polling for mass value
Do Until txtMass.Value <> 0 ' this is a screen field
DoEvents 'let other stuff happen
Set rs = CurrentDb.OpenRecordset("tblReadings")
If rs("Mass") <> 0 Then 'if field is filled
txtMass.Value = rs("Mass") 'get value
txtNetMass.Value = txtMass.Value - txtTare.Value
rs.Edit
rs!Mass = 0
rs.Update
End If
rs.Close
Loop
Is there some way to make this loop end when the close button is selected??
Here is the code:
'begin polling for mass value
Do Until txtMass.Value <> 0 ' this is a screen field
DoEvents 'let other stuff happen
Set rs = CurrentDb.OpenRecordset("tblReadings")
If rs("Mass") <> 0 Then 'if field is filled
txtMass.Value = rs("Mass") 'get value
txtNetMass.Value = txtMass.Value - txtTare.Value
rs.Edit
rs!Mass = 0
rs.Update
End If
rs.Close
Loop