Hiding/Showing a Field

leo31

Registered User.
Local time
Today, 11:47
Joined
Feb 16, 2008
Messages
21
How do I hide a field by default then display it based on a checkbox being clicked?

Thanks!
 
hide it when the form opens.
 
In the field properties you can set the visible property to no.

Then on the checkbox after update event, you can add the line of code
Code:
 me.fieldname.visible = true
 
thanks.

However, not being familar with this type of coding in Access, do I just paste that into the properties dialogue area for update event, or put it in expression builder etc....

should 'me' be the text me, or a form name etc...
 
You'll want to use the code builder in this case -- it'll open up the VB code window.

The Me term refers to the current form, saving some code vs typing
forms![formname].controlname
Me.controlname is the same thing as long as the info is on the current form.

Just replace fieldname with the name of your field and you'll be good to go.
 
ah, thanks. Yes, it sort of works, but this is a continous form and it seem to show them all. I think I also it need to be in some sort of checkbox equals true option instead of after update? Any ideas?
 
Continuous forms throw a whole new wrench into things. Visibility will affect every record in the form, since Access basically says that there is only one text box, no matter how many rows you have.

As far as making it visible on true only, your code would be something like this:

Code:
if me.checkbox then
     me.textbox.visible = true
else
     me.textbox.visible = false
end if
 
hmm, ok, so I cant do it then? The code you gave me refers to textboxes? It tried it with fieldnames and put the checkbox name, ie Check20 inplace of checkbox, but it throws a wobbly!
 
To make this easier, what is the name of the checkbox you are checking, and what is the field you're trying to make visible?

I was assuming you were trying to make a textbox visible (you'd put the name of whatever field you want to make visible in place of textbox). It doesn't have to be a textbox, it could be another checkbox or combobox or anything
 
ok, sorry.

I have a combo dropdown called LimitedEditionTotal which stores a values, 10, 20 etc... and a checkbox called Check20 (default name) that I want to use to control the visibility of the LimitedEditionTotal field.

I have set the default visibility to false as WAZZ above suggested.

I would like it hidden when you first create a new record, then controlled by the checkbox there after.
 
Okay... the best way to hide the field on a continuous form is to use the current event of the form.

Go to the form properties, and select the current event - use the code builder to paste this code:

Code:
if me.Check20 then
    me.LimitedEditionTotal.visible = true
else
    me.LimitedEditionTotal.visible = false
end if

Also paste this same code in the Check20 AfterUpdate event.

That should accomplish what you want.
 
that seems to apply to all the fields again, and produces a debug error on a new entry :-(

Just to clarify, I trying to hide the entry in 1 field in 1 record of the continous form. The code above applys the the field across all records in the continous form
 
Last edited:
With continuous forms, anything you do to change the visibility of an item will affect the same item across all of your records.
 
ah, ok thanks. What would happen if I apply this code to a single version of the form, but then look at the continous version. Would it do strange things?

I'm sure I can use this code somewhere so all is not lost. Thanks for your help.


***
I guess it wouldnt effect the continous form as it is a different form so the settings wont apply!
 
Last edited:
Try conditional formatting.

Do want to make the entry/typing in the textbox invisible or the whole box itself?

If the entry/typing then with conditional formatting you change the font colour to be the same as the textbox background colour. To make the textbox invisible then change it to transparent background.
 

Users who are viewing this thread

Back
Top Bottom