how to compare current contents between two combo boxes?

rovolution2

Registered User.
Local time
Today, 09:50
Joined
Jul 29, 2008
Messages
20
I have a form with two combo boxes on it, and i want to create a valid If statement that will execute some code that if the current contents of the two combo boxes (SelectProg and SelectAW) are equal to one another.

I tried this statement but I keep getting an error. Any explanations?


Private Sub Form_Current()
If Me![SelectProg].Text = Me![SelectAW].Text
Me.Graph10.Visible = False
End If

End Sub


Also, what section of the form code should something like this be contained in if not the Current section?
 
Hi,

try using Me.ComboName.Column(index goes here)

if you have 1 column in the combo, index should be 0, and if you have 2 columns then index should be 1
 
i still keep getting a wierd Then if Go To error every time i leave that line.

Heres what i put

Private Sub Form_Current()
If Me.SelectProg.Column(8) <> Me.SelectAW.Column(0)
Me.Graph10.Visible = False
End If

End Sub


still raising errors
 
If Me.SelectProg.Column(8) <> Me.SelectAW.ItemData(0) THEN

Try that where it's bolded
 
it stopped raising the error thanks to the "THEN" suggestion, but i still dont know which section of the form to put the code in
 
Hi,

as twoplustwo stated you're omitting the THEN, but on the other hand are you sure that your combo has a column count of at least 8?
 
You'll have a value in the first one from selecting an option. Then select a second value in the second combo. I mena you seem to have something that'd work here: If Me.[v]SelectProg[/b].Column(8) <> Me.SelectAW.Column(0) if they're both combo boxes and you've selected the correct columns to display.
 
Hi,

as twoplustwo stated you're omitting the THEN, but on the other hand are you sure that your combo has a column count of at least 8?


I did this b/c of the following properties of my first combo box:

Row Source Type: Table/Query

Row Source: Delivery (a type of table)

Bound Column: 9 (This is the column on the table where i need the data for the combobox to come from)

Column Count: 9

Column Widths: 0";0";0";0";0";0";0";0";1"





but should i still put 0 on the column specification?
 
Everyone, thank you sooo very much!!! It all works like a charm now!!!


Private Sub SelectAW_AfterUpdate()
If Me.SelectProg.Column(0) <> Me.SelectAW.Column(0) Then
Me.Graph10.Visible = False
End If
End Sub



One more question...Since the SelectAW values are actually numbers and the SelectProg values are text, can I create a text option in both boxes called something like "All" and if so, how would do something like that? Thanks
 

Users who are viewing this thread

Back
Top Bottom