Error Checking

scantor145
11-25-2003, 05:57 AM
Below is a portion of a macro that is to check to see if a value was entered into a text box called txtCalConc. If no value was entered then I have a warning message screen pop up. I then reset the focus on the text box.

Problem: The message appears with no trouble, however, when I the select OK button, although I saw that focus was set on the textbox, the form disappeared immediately and the macro proceeded as normal.

What statement do I need after

frmOptions.txtCalConc.SetFocus

to go back to the form and enter an appropriate value?



Private Sub cmdContinue_Click()

Dim Press As Single

If frmOptions.chkCal = True And frmOptions.txtCalConc = "" Then

Press = MsgBox("Enter a concentration for the Calibrator", vbCritical)
frmOptions.txtCalConc.SetFocus

End If

frmOptions.Hide
Call NewWork

End Sub

Insomniac
11-25-2003, 06:30 AM
Only had a quick look, but I think you want something like this:Private Sub cmdContinue_Click()

Dim Press As Single

If frmOptions.chkCal = True And frmOptions.txtCalConc = "" Then

Press = MsgBox("Enter a concentration for the Calibrator", vbCritical)
frmOptions.txtCalConc.SetFocus

Else

frmOptions.Hide
Call NewWork

End If

End Sub

mark007
11-25-2003, 08:18 AM
or


Private Sub cmdContinue_Click()

Dim Press As Single

If frmOptions.chkCal = True And frmOptions.txtCalConc = "" Then

Press = MsgBox("Enter a concentration for the Calibrator", vbCritical)
frmOptions.txtCalConc.SetFocus
Exit sub
End If

frmOptions.Hide
Call NewWork

End Sub

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum