Hiding Field on Certain Conditoin

bennybee

Registered User.
Local time
Today, 17:18
Joined
Jan 13, 2004
Messages
50
I have a form where i want to hide some fields unless a certain condition is selected from another field.

ie. there is a field called Decision, and in it it has the following values:
Suspended
Cancelled
Approved

when the user selects "Suspended" i want the form to display the following fields -
Date_From, Date_Till, Number_Days, Suspension_Type, Suspension_Section.

is there a way of hiding these fields unless the value "Suspended" is selected from the Decision field.
(ie. to stop users from entering in suspension data when they select Cancelled for example)

any help?:confused:
 
bennybee said:
I have a form where i want to hide some fields unless a certain condition is selected from another field.

ie. there is a field called Decision, and in it it has the following values:
Suspended
Cancelled
Approved

when the user selects "Suspended" i want the form to display the following fields -
Date_From, Date_Till, Number_Days, Suspension_Type, Suspension_Section.

is there a way of hiding these fields unless the value "Suspended" is selected from the Decision field.
(ie. to stop users from entering in suspension data when they select Cancelled for example)

any help?:confused:

We'll i assume your talking about a combobox, so this is what the code would look like to enable and disable that....

Code:
If Me.Decision = "Suspended" Then
     Me.Date_From.Visible = True
     Me.Date_Till, Number_Days.Visible = True
     Me.Suspension_Type.Visible = True
     Me.Suspension_Section.Visible = True
Else
     Me.Date_From.Visible = False
     Me.Date_Till, Number_Days.Visible = False
     Me.Suspension_Type.Visible = False
     Me.Suspension_Section.Visible = False
End If

You may want to read about naming techniques for your database (example, Decision could be named txtDecision)

But that should work, just copy and paste the code into the AfterUpdate Event. You may want to set the fields that will be used to: Visible = "No" in the property settings for each.

Have a great day!
________
Marijuana Sativa
 
Last edited:
ok that works well.
but when i create a new record, it still shows up the fields that are supposed to be hidden.

i mean it doesnt show up any of the fields until i select "Suspended' from the list. and that is how i want it.
but when i create a new record, the fields are still visible. how do i hide them again??
 
bennybee,

a.sinatra already gave you the answer to this when they said:

You may want to set the fields that will be used to: Visible = "No" in the property settings for each.

If I were you I would also repeat the code to set the fields as visible or not on the 'On Current' event of the form.

Cheers

Flyer
 

Users who are viewing this thread

Back
Top Bottom