field visibility conditional on a value

gussy

Registered User.
Local time
Today, 20:35
Joined
Aug 13, 2003
Messages
41
Hi folks

I'm wanting to display, or not display, certain fields in a form dependent on the value of one of the fields.

eg, if the value of field 1 is say "fred" then I want it to display fields 2 & 3, but either grey out or not show fields 4 & 5. If the value of field 1 is say "John", then show 4 & 5, but grey out 2 & 3.

The visibility parameter for each field is only yes or no, so on the face of it doesn't seem to allow any simple coding....

Any ideas?

Thanks in anticipation.
 
First, you are not talking about Fields - you are talking about Controls. More specifically, the textbox control.

Code:
If Me.txt1 = "Fred" Then
    Me.txt2.Visible = True
    Me.txt3.Visible = True
    Me.txt4.Visible = False
    Me.txt5.Visible = False
Else
    Me.txt2.Visible = False
    Me.txt3.Visible = False
    Me.txt4.Visible = True
    Me.txt5.Visible = True
End If


You'll probably want it in your form's Current event.
 
Cheers, thanks Mile-o once again....
 
Are there really only two conditions basd on name or is their multiple possibilities?
 
Probably about 4 or 5....

guess I would use a 'case is' function?
 
gussy said:
Probably about 4 or 5

The word "probably" is what's going to cause more problems than anything else - it demonstrates that you haven't thought about this until you've got to the form design stage.

And, yes, a SELECT CASE statement would be the way to go...
 
Yeah, the "probably" stems from the fact that I'm adapting a database I put together before. I'm actually breaking away part of the original to start a new one in a different direction, so I'm just trying out a few thoughts, hence the vagueness. :D
 

Users who are viewing this thread

Back
Top Bottom