Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text Box Visible/Invisible

Status
Not open for further replies.

Quan9r

Technical User
May 18, 2000
36
US
I have a combo box for MALE or FEMALE:
I would like to make a text box disappear when I select MALE
I'm not very VB savy - here is what I got so far

Select Case Me.Combo28
Case "MALE"
Me![Text40].Visible = False
End Sub


Thank you
 
I suggest you put something in the afterupdate event of the combo box..
If combo123 = MALE Then
Me![txt40].Visible = False
End IF

I hope it helps or at least drives you in the right direction. Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum immane mittam.
 
Hi

Set combo 28 to run an event procedure on the Upon Change field and use the following code

Private Sub Combo28_Change()
Select Case Me.Combo28
Case "MALE"
Me![Text40].Visible = False
Case "Female"
Me![Text40].Visible = True
End Select
End Sub


(I added the Female option incase someone picks male by accident)

Is this OK?


David Lerwill
"If at first you don't succeed go to the pub"
 
A couple of minor but important corrections to the above post:

(a) Quotes around MALE
(b) Add an Else part, to ensure the control becomes visible again if "FEMALE" is selected;

The AfterUpdate event then becomes:

If Me!combo28 = "MALE" Then
Me![txt40].Visible = False
Else
Me![txt40].Visible = True
End IF

You will probably also need to consider using this code in the OnCurrent event, to ensure that the behaviour is consistent when you change from one record to the next.

Cheers,

Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
 
David,
Suggest that the OnChange event is not appropriate here. It gets triggered for each keystroke! Rather, use the AfterUpdate event, which only gets triggered once after the user has made his/her selection. Cheers,

Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
 
Thanks for the tip Steve David Lerwill
"If at first you don't succeed go to the pub"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top