Help making a contron visible

mrgreg64

New member
Local time
Yesterday, 23:46
Joined
Feb 14, 2013
Messages
6
I would greatly appreciate any help I can get with this. I am trying to get a text box to become visible once I make a certain selection in a combo box. I have read several post in reference to this but still cannot get it to work. I am using Access 2010. Please refer to the following information:

Form name: Assign equipment

Combo box name: EquipmentType

Combo box selections: laptop, desktop, Secure Token, Cell phone, Air card

Text Box name: TokenSerialNumber

The visible category under properties for the text box is no.

What I want the form to do is when "Secure token" is selected in the EquipmentType combo box, the TokenSerialNumber text box becomes visible on the form.

Current code:
Private Sub EquipmentType_BeforeUpdate(Cancel As Integer)
If Me.EquipmentType = "Secure Token" Then
Me.[TokenSerialNumber].Visible = True
Else
Me.[TokenSerialNumber].Visible = False
End Sub

The funny thing is when I change the visible property of the text box to yes, the text box displays on the form and when I select Secure Token in the combo box it disappears.

What am I doing wrong?
 
Make sure the bound column of the combo isn't an ID field or something.
 
Try to put it on AfterUpdate event.
 
The bound column is not an ID field and the code is under an after_update event but it still is not working. Don't know if this makes too big a difference but TokenSerialNumber is a combo box, not a text box as I stated in the original post.
 
Set a breakpoint or use Debug.Print to test the value in the combo at runtime.
 
Make sure that EquipmentType visible property was set to NO
It works, i am using Access 2007


Private Sub EquipmentType_AfterUpdate()
If Me.EquipmentType = "Secure Token" Then
Me.[TokenSerialNumber].Visible = True
Else
Me.[TokenSerialNumber].Visible = False
End If
End Sub
 
Re: Help making a control visible

mikejaytlabustro: Did you mean to say make sure that the TokenSerialNumber visible property is set to no (which it is)? If I set the EquipmentType visible property to no then I will not be able to see it when the form opens.
pbaldy: Please explain how to use the debug.print or breakpoint feature. I am not familiar with neither.

I have figured out that for some reason it is not reading the selection in the EquipmentType combo box. I created a text box and typed Secure Token (using the same after_update code) and it worked fine.

More information:
EquipmentType combo box properties
Visible: yes
Column Count: 2
Column width: 0";2"
Bound column: 1

TokenSerialNumber combo box properties
Visible: no
Column Count: 1
Column width: 01"
Bound column: 1
 
Try this:

If Me.EquipmentType.Column(1) = "Secure Token" Then
 
OK. Changing it to

If Me.EquipmentType.Column(1) = "Secure Token" Then

worked to get it to show but now once Secure Token is selected the TokenSerialNumber combo box appears on all the records no matter what was previously entered in EquipmentType. In other words the Else statement is not working.

Appreciate you and everyone helping me out with this.
 
So as I suggested in post 2, the bound column was an ID field. Is the form in continuous or single view? Either way, you'd need the same code in the current event of the form to handle changing records. In a continuous form, the code will treat all records like the current one; you won't get a different look in each record. You could use Conditional Formatting.
 

Users who are viewing this thread

Back
Top Bottom