hide blank fields on a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I hide fields that I'm not using in Access but be able to see them
again when they become relevant?

Example: If I check a yes/no box a field wopuld appear for more information
but if I didn't check that box then the field would not appear. Also, I want
fields to appear, remain hidden or disappear depending on other fields' input.

Is this posibble and, if so, how do I do it?

Thanks.
 
Let's use your example for this. In the After Update event of the check box:

If Me.ChkBoxName = True Then ' We want to see the text box
Me.txtOtherControl.Visible = True
Else
Me.txtOtherControlVisible = False
End If

or

Me.txtOtherControl.Visible = Me.txtChkBoxName

Either one of these will do.

One other thing, Forms do not have fields. Fields are part of a table.
Forms have controls.
 
In the after update property of the check box field, enter the code
if me.checkbox = true then ' mark on
me.field1.visible=true
me.field2.visible=true
else
me.field1.visible=False
me.field2.visible=False
End if

make sure you call this sub on the on current event of the form, so when you
move from one record to another it will trigger that code.

To hide fields that has no values you can use
if isnull(me.field1) then
me.field1.visible=false
else
me.field1.visible=true
end if
 
cswebdev said:
How do I hide fields that I'm not using in Access but be able to see them
again when they become relevant?

Example: If I check a yes/no box a field wopuld appear for more information
but if I didn't check that box then the field would not appear. Also, I want
fields to appear, remain hidden or disappear depending on other fields' input.


Use the check box's AfterUpdate event to set the other
control's Visible property. Maybe something like:

Me.other.Visible = (Me.checkbox = True)

or

If Me.somecontrol1 > 5 And Me.somecontrol2 = "xxxx" Then
Me.other.Visible = True
Else
Me.other.Visible = False
End If
 
Yes. Alter the .ENABLED property of the control. Setting the property to
FALSE will disable the control and show it on the form. If you want to
completely hide the control, alter the .VISIBLE property. Keep in mind
that the properties do no work in tandem. Just because a control's
VISIBLE property is set to true, does not mean that it is ENABLED. You
have to set both to TRUE in order to add/edit/delete data in the control.
 
Back
Top