I'm writing code where I look through more than two combo boxes (after a user has made their selections), click a command button to check to see if they match or not, and print the results in a caption.
When I work with simply two combo boxes;
Code:
Dim Rig1st As String
Dim Lenses1st As String
If Me.cmbARig & Me.cmbBRig <> 0 Then
If Me.cmbARig = Me.cmb1stCamBRig Then
Rig1st = "2 x " & Me.cmbARig.Column(1)
Me.lblRigs.Caption = Rig1st
Else
Rig1st = "1 x " & Me.cmbARig.Column(1) & vbNewLine & "1 x " & Me.cmb1stCamBRig.Column(1)
Me.lbl1stRigs.Caption = Rig1st
End If
Else
Me.lbl1stRigs.Caption = ""
End If
The above works great. As you can see in the second 'If' line, I'm simply checking to see if the combo boxes ID's (their number fields) match.
However, if I try to apply the same logic / syntax to check through four combo boxes like this (and for this example I simply stopped at what happens if you choose the same in all four boxes);
Code:
If Me.cmbALens1 & Me.cmbLens2 & Me.cmbBLens1 & Me.cmbBLens2 <> 0 Then
If Me.cmbALens1 = Me.cmbALens2 = Me.cmbBLens1 = Me.cmbBLens2 Then
Lenses1st = "4 x " & Me.cmbALens.Column(1)
Me.lblLenses.Caption = Lenses1st
Else
Me.lblLenses.Caption = "Formula Not Working"
End If
Else
Me.lblLenses.Caption = "Formula Still Not Working"
End If
Then my caption box shows the "Formula Not Working". What am I doing wrong in my logic of trying to see if all boxes have the same value? And also, what would the syntax for exclusion be (e.g. cbo1 = cbo2 = cbo3 <> cbo4), because I will be coding messages for that as well?
Thanks