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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

conditional field

Status
Not open for further replies.

myriad46

Instructor
Apr 21, 2004
18
0
0
US
Is there a way to not have a text box appear until another field is a particular value. For example, a form asks you for your job title and there are 15 choices in a list box, including "other". If "Other" is selected in the list box, can i have another field that is otherwise not visible appear that would allow the user to fill it in, recording that text entry in the same table field as the original list box? Any help would be appreciated. Thank You.
 
In the listbox after update event....

if me.lboListBoxName = "Other" then
me.txtTextBoxName.Visible = True
else
me.txtTextBoxName.Visible = False
end if



Randy
 
Looks good, but my computer cannot find the Macro "if me."
Ed
 
Here is what i have. Other is the name of the text box where i want to be able to enter data and InfoSource is the name of the list box where the other choices are.
Thanks

Private Sub InfoSource_AfterUpdate()
If Me.lboInfoSource = "Other" Then
Me.txtOther.Visible = True
Else
Me.txtOther.Visible = False
End If
End Sub
 
Hi!

You're executing an afterupdate on a control named "InfoSource", then you must also refer to that name in the code, here using another notation:

[tt]Me!txtOther.Visible = (Me!InfoSource = "Other")[/tt]

- You're also sure the list's bound coulumn is the column where the value "other" might occur? If not, to for instance use the second column of a list:

[tt]Me!InfoSource.Column(1)[/tt]

Roy-Vidar
 
InfoSource is the name of the list box
If Me.lboInfoSource = "Other" Then


If InfoSource is the name of your control, InfoSource must be the name you use to refer to it.

Code:
Private Sub InfoSource_AfterUpdate()
If Me.InfoSource = "Other" Then
     Me.txtOther.Visible = True
Else
     Me.txtOther.Visible = False
End If
End Sub

This assumes the actual value stored in the list box is, in fact, "other". If your box has more than one column, you need to refer to the bound column. This means that if, for instance, the list box is based on a table of job titles, you should use that value in the IF line (if me.infosource = 15).

Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top