Making blank fields hidden on a form

R

rye1982

Hello,

When my form loads, I'd like it to check if a certain couple of fields are
blank, and if so, make them invisible. How can I do this?

Also, is it possible to shift other fields up when one becomes invisible?
For example, it would normally appear as:
Field 1
Field 2
Field 3
But if Field 2 was blank, it would appear as:
Field 1

Field 3
Yet I want to be able to have it appear as (if Field 2 was blank):
Field 1
Field 3

Any help would be appreciated.

Thank you.
 
M

Mr B

rye1982,

First, forms do not have fields. Tables have fields. Forms have controls.
Controls can be bound to fields, but controls can also be unbound and still
provide functionality in certain situation. It will help you in future
posting if you refer to the actual object types that you are needing help
with.

With that said, all you are wantiing to do is possible. However, you will
need to use either a macro or some VBA code to accomplish any of the things
you want to do.

I would suggest that you use VBA code for your purposes. Just how the code
will need to be written will depend, to some degree, on what type of data is
being evaluated. If you are dealing with only text then you could use some
code in the OnCurrent event of your form like:

If IsNull(me.NameOfFirstControl) Then
Me.NameOfFirstcontrol.Visible = False
End If

You could repeat the code above (changing the "NameOfFirstControl" to the
actual name of the control you are evaluating) and use it for each control
that you wish to check.

If you have other types of data, such as a numeric value where the default
value of the field bound to the control is zero, then you would use a
different statement. Something like:

If Me.NameOfFirstControl = 0 then
Me.NameOfFirstControl.Visible = false
End If

Hopefully this will shed a little light on how you can accomplish your
needs. If not, please post back and I or someone else will try to help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top