Command button test field

BBRAZEAU

New member
Local time
Today, 08:02
Joined
Aug 14, 2001
Messages
7
I would like to have a command button in a form that opens another form ,first test the value of a check box.Based on the result the button would either open the form allowing access to it or inform the user that the check box must be checked first.The following code checks a text box for null and either grants or denies access to the form.Anyone know how to make it check the status of a checkbox?

Private Sub My_form2_Click()
On Error GoTo Err_My_form2_Click
If IsNull(Me![My_text]) Then
MsgBox "Mytext must entered before opening My_form2 form."
Else
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenForm "My_form2"
End If

Exit_My_form2_Click:
Exit Sub

Err_My_form2_Click:
MsgBox Err.Description
Resume Exit_My_form2_Click
End Sub
 
assuming [My_text] is boolean (a check box);

try replacing your if statement with:

------------
If Me![My_text] Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenForm "My_form2"
Else
MsgBox "Mytext must entered before opening My_form2 form."
End If
-----------

hth,
al


[This message has been edited by pcs (edited 08-18-2001).]
 
Checkbox is boolean

So:

If Me.Checkbox1.Value = True Then
DoCmd.OpenForm stDocName
Else
Msgbox "Check the Checkbox First!"
me.checkbox1.setfocus
End If
 
either of the above will work...

If Me.Checkbox1.Value = True Then
and
If Me![My_text] Then
will both evaluate correctly...

If Me.Checkbox1.Value = True is bit easier to understand.

hth,
al
 
I don't wish to appear pedantic here but you don't need .Value just If Me.Checkbox = True Then etc
 

Users who are viewing this thread

Back
Top Bottom