Checking Values of 2 Combo Boxes

Paul Cooke

Registered User.
Local time
Today, 23:45
Joined
Oct 12, 2001
Messages
288
Hi Guys, could someone please guide me on how to do this please as I am confusing myself !!

I have 2 combo boxes

CBO1
CBO2

A user must select a value in at least 1 of the boxes. e.g if they do not select a value in CBO1 then they must select a value in CBO2 (or visa versa)

Once they have selected a value in one of the boxes the rest of the controls on the form are enabled. (they are set as diabled by default to ensure the user cannot enter anything on the form without selecting a value from one of the boxes first).


I have been able to set up some code to check CBO1 and enable a control - as below
Code:
Private Sub cbo1_LostFocus()
If IsNull(Me.cbo1) Then
Me.txt1.enabled = False
Else
Me.txt1.enabled = True
End If
End Sub

This works fine and I am assuming I just add the other controls that need enabling under the first one? e.g.

Code:
Private Sub cbo1_LostFocus()
If IsNull(Me.cbo1) Then
Me.txt1.enabled = False
Me.txt2.enabled = False
Me.txt3.enabled = False
Else
Me.txt1.enabled = True
Me.txt2.enabled = True
Me.txt3.enabled = True
End If
End Sub

The issue I have is how do i code it to check both boxes against each other?

so if CBO1 is null but CBO2 is not null then the other controls will be enabled (or the other way around) but if both CBO1 and CBO2 are null the controls stay disabled.

I hope this makes sense !!

I would be very grateful for any adivse you can offer.

Many thanks
 
Code:
Private Sub cbo1_LostFocus()
If IsNull(Me.cbo1) and IsNull(Me.cbo2) Then
Me.txt1.enabled = False
Else
Me.txt1.enabled = True
End If
End Sub
 
 
Private Sub cbo2_LostFocus()
If IsNull(Me.cbo1) and IsNull(Me.cbo2) Then
Me.txt1.enabled = False
Else
Me.txt1.enabled = True
End If
End Sub

If both are null then disable controls, else (i.e. if either or both are populated) enable them.
 
wow thnks for such a fast reply !

I was thinking along those lines just wasn't sure

Many thanks again
 

Users who are viewing this thread

Back
Top Bottom