Conditional If function in VBA

S

sunilkeswani

how do i make any one of 4 check boxes check1, check2, check3, check4
mandatory, only if the combo "cboName" has entries for a particular
list of names?

i.e I want speicific users to mandatorily select one of the 4 check
boxes, but not all.

Cheers
 
D

Douglas J Steele

In the form's BeforeUpdate event, put code that checks whether it's one of
the appropriate users. If it is, make sure that they've selected at least
one of the checkboxes.

An easy way to check whether at least one checkbox is selected is:

If Me.check1 Or Me.check2 Or Me.check3 Or Me.check4 Then
' At least one is checked
Else
' None are checked
End If

To check if all are selected, use

If Me.check1 And Me.check2 And Me.check3 And Me.check4 Then
' All four are checked
Else
' At least one isn't checked
End If
 
S

SusanV

If you only want them to select ONE of the 4 boxes, perhaps you would be
better off using Option Buttons (radio buttons).
 
B

BruceM

You should either stay in the original thread or start a new one, but not
both. Scattering the same question in multiple postings is not good
newsgroup etiquette.
 
S

sunilkeswani

But I want this to be atleast one condition only if the value in
another combo box is x, y or z

How can I do this?
 
D

Douglas J Steele

As I said, put logic to check whether it's one of those!

If Me.MyComboBox = "x" _
Or Me.MyComboBox = "y" _
Or Me.MyComboBox = "z" Then

' Check the checkboxes

End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top