Require fields and msgbox

Anhjan

New member
Local time
Today, 13:19
Joined
Jun 26, 2002
Messages
9
Please help, I'm a newbie...I don't know VBA all that well (I know those newbie can be a pain...)

I'm trying run a code that require one of two check box fields to be checked. If both are checked or if neither are checked, a msgbox appears and the user cannot save the record until only one is checked. If one of the two is checked, then I run a macro.

Well here's my code:
Private Sub update_proj_button_Click()

If (Me.top_1000 = 0 And Me.Never_out = 0) Or (Me.top_1000 = 1 And Me.Never_out = 1) Then
MsgBox "Most chose only one", vbOKOnly
DoCmd.CancelEvent
Else
DoCmd.SetWarnings False
DoCmd.OpenQuery "update to oprj", acNormal, acEdit
DoCmd.SetWarnings True
DoCmd.Requery

I keep getting an compile error...

Any ideas? I appreciate any assistance...
 
You forgot the "Endif" statement.

A different approach might not be a bad idea.

An group of option buttons might be better than 2 check boxes since you only want people to choose one at a time. If you insist on using check boxes you can place code in the Click Event of each check box that will check to see if the other box is checked... and if it is, disable the other box.
 
THANKS...JC10001...I feel like an idiot..."End IF" so simple!

As for your idea of the option buttons, how wohe group of would I set the group of button to be only one or the other?
 

Users who are viewing this thread

Back
Top Bottom