View Full Version : CheckBox Selection Only after Text Box Entry


gyli84
08-09-2001, 01:03 AM
I have a form with a checkbox. I only want the user to be able to select the check box and change the status to "yes" after text has been typed in a text box (say this text box is called textbox1 and the check box is called checkbox1). I would be grateful if anyone had an idea as to how this can be done. Thanks.

Rich
08-09-2001, 01:30 AM
Use the before update event of the check box to check for null entries in your text box something like If IsNull(Me.txtboxName) Then
MsgBox "Whatever"
txtboxName.SetFocus
EndIf
HTH

gyli84
08-09-2001, 05:04 PM
What is the "Me." section of the code? When I try to click the checkbox it now says it cannot find the macro "If IsNull(Me." Also, what does "TxtBoxName.SetFocus" do?

THanks

KeaganQuilty
08-10-2001, 04:58 AM
Click on your checkbox in design view and go to properties. Click the event tab, and where it says "On BeforeUpdate" choose "[Event Procedure]", and click the build button (that thing with the three dots). When the code window opens, put in the following five lines ofcode exactly as they appear.

If IsNull(me.textbox1) Then
MsgBox "Cannot change this value when field is blank"
textbox1.setfocus
Cancel = -1
End If


"Me." refers to whichever form you happen to have open.

txtbox.setfocus moves the cursor into the field of that name.

If you have any more trouble, let us know

Keagan Quilty
Kilbride, Newfoundland