Using a combobox selection in an IF statement to make another text box visible

PlasticMonster

Registered User.
Local time
Today, 20:32
Joined
Aug 21, 2012
Messages
30
As previous ill start with im still learning..

Ive gone through pages of internet searches but nothing pertinent seems to come up making me think its something small im missing out.

I have a combobox [CBreason] that reads from a table to show me why someone is gaining access to the building.

One of the options is "Incident".

When incident is selected I want a textbox [TBIncidentNo] and a button[BIncidentDup] control I made to appear.

I thought that the code:

If Me.CBReason.Value = "Incident" Then
Me.CBIncidentNo.Visible = True
Me.BIncidentDup.Visible = True
Else
Me.CBIncidentNo.Visible = False
Me.BIncidentDup.Visible = False
End If

Placed in the after update action of the CBReason box would sufice but it doesnt work :(

I'm guessing the value is not recognised fro some reason but i cant work out why. There is no error message or issus, it makes the box dissapear when there is no entry but no change for selecting incident.

Please help. Im going mad, two days on this so far reading and testing, running out of ideas now.:banghead:
 
Try;
Code:
If Me.CBReason.Column([B][COLOR="Red"]x[/COLOR][/B]) = "Incident" Then
Me.CBIncidentNo.Visible = True
Me.BIncidentDup.Visible = True
Else
Me.CBIncidentNo.Visible = False
Me.BIncidentDup.Visible = False
End If

Where x represents the column in your combo that hold the value you are testing for. Remember that the columns in a combo or list box for that matter are numbered from zero on up.
 
Thankyou, that solved it.

There seemed to be a hidden column (im guessing ID) so it was checking that instead, when I changed the column number to 1 it worked straight away.

This wont be one I wont forget in a while....
 
You can also use;
Code:
ComboName.Text
to return the field selected (and visible) in the combo
 

Users who are viewing this thread

Back
Top Bottom