Unhide hidden fields

bobz

New member
Local time
Today, 10:39
Joined
Oct 31, 2014
Messages
2
Hello everybody,

I'm quite new to Acces (2010) and I need help with some coding!
Currently, I'm working on a form in which certain fields are set to invisible. I'd like to toggle fields to visible based on the button clicked.

Example:
Field 1: O No O Yes --> When No is clicked Field 2 (containing a date) becomes visible
--> When Yes is clicked Field 3 and 4 (both yes/no fields) become visible

As said before: I'm new to access and kind of a newbie so my apologies if this is a silly question!
 
Last edited:
Hey Bob,

i would set a Event Procedure on each Button Properties "On Click" event with the following statement: (formname being your form name)

-No button procedure

Forms![formname].[field2].Visible = True
Forms![formname].[field3].Visible = False
Forms![formname].[field4].Visible = False

-Yes Button procedure

Forms![formname].[field2].Visible = False
Forms![formname].[field3].Visible = True
Forms![formname].[field4].Visible = True

Thanks !
 
Typing this on my phone, so not 100% sure of every part, but the gist is as follows.
Open form in design view,select Field1 and click Properties. Under Events, click the three dots on the After Update line and then select Code Builder.

The first and last lines of the code will be completed for you. Between them, enter the following
If Me.Field1.Value=1 Then
Me.Field2.Visible=True
Else
Me. Field2. Visible= False
End If

Save the form and now open it in Form view and the visibility of Field 2 should toggle depending on whether or not you have 1 in Field 1.

I hope this helps.
 
Just re-read your question and realised you have Yes/No rather than 1 or zero. But hopefully you get the idea.
If Field1. Value= "Yes"
 
Thanks alot for the replies:)!
I followed the instructions of Big Pat and it worked like a charm.
Yes corresponded with the value 1 and No with 0 so Big Pat's first reply worked out for me.

Cheers!
 
Just an add: All the code that Big Pat gave you can be written in a single line:
Me.Field2.Visible = (Me.Field1.Value = 1)
 

Users who are viewing this thread

Back
Top Bottom