Showing or hiding a control based on combo box selection

Leebo86

Registered User.
Local time
Today, 17:57
Joined
Dec 20, 2012
Messages
14
Access newbie here...

I have a form where the user must select an option from combo box.

On some of these options, I want a comment text field to appear which must be filled out by the user.

In preparation for this, I added a yes/no field to the table where the options are stored for determining whether each option requires the comment control or not.

Only... I have no idea what I need to do in the form to make the control appear or disappear based on the user's selection.

Thoughts?
 
Thanks, that looks like it will help.
 
No problem. Post back if you get stuck.
 
Hi there -

i have this code in my form, but the text fields are not displaying after the combo box is updated - they are displaying after the record is saved. The code is in the after update event for the combo box that triggers the need for the text boxes - what else do I need to add?
 
Here's the code:
Private Sub PublicationType_AfterUpdate()
Select Case Me.PublicationType.Column(3)
Case "TN"
Me.txtTechNoteNum.Visible = True
Me.labTechNoteNum.Visible = True
Me.txtPlantSym.Visible = False
Me.labtxtplantsym.Visible = False
'Me.txtPlantSym.value = Null
Case "FS"
Me.txtTechNoteNum.Visible = False
Me.labTechNoteNum.Visible = False
Me.txtPlantSym.Visible = True
Me.labtxtplantsym.Visible = True
'Me.txtTechNoteNum.value = Null
Case "PG"
Me.txtTechNoteNum.Visible = False
Me.labTechNoteNum.Visible = False
Me.txtPlantSym.Visible = True
Me.labtxtplantsym.Visible = True
'Me.txtTechNoteNum.value = Null
Case Else
Me.txtTechNoteNum.Visible = False
Me.labTechNoteNum.Visible = False
Me.txtPlantSym.Visible = False
Me.labtxtplantsym.Visible = False
End Select
 
Looks okay offhand. Those are the values in the 4th column of the combo's row source? What is the column count property?
 
Hey! Column count property is set to 5 - data type (PG, FS, or TN is in column 5. Thanks for getting back on this one!
 
This is looking at the 4th column, not the 5th:

Select Case Me.PublicationType.Column(3)

You might set a breakpoint so you can see what value is being returned, or add:

Debug.Print Me.PublicationType.Column(3)
 
You're right - I think I had to add a column to the query and forgot to change the 3 to a 4. But - even so - it doesn't change the outcome. The text boxes still don't display after one of the cases is selected - they only appear after the record is saved, and not the field update.

I'm afraid I am still quite new at this, and don't know where to put the debug line. I tried a few places and ran debugger and it just dings at me. i inherited this particular project, so I'm learning as I go...
 
I GOT IT!! The column number WAS the culprit! As I said - new at this. I was thinking the column number referenced was the column number where the data I wanted was in the QUERY. I hit the datasheet view of the query, and realized the data I wanted was in column 0 - made that change, and BAM! All is working perfectly now.

Thanks so much for your help - I never would have thought about the column number being wrong.

I'm just beginning to sort out all the issues with the db - I'm sure you'll see my name again...

Thanks again!! :p
 

Users who are viewing this thread

Back
Top Bottom