make a Field visible

R

Raul Sousa

I have a form with two fields (field A and field B).
I want field B to be visible only if field A has any
values.
I was thinking on Field B invisible and on an after
update Field A event to make it visible. Does any one
have a better idea?
The problem is that I do not know the code to make a
field in(visible), can some one give me an hint?

Thanks
 
J

Joe Fallon

Hint:

If Me![txtData]="" Then
Me![txtName].Visible=False
Else
Me![txtName].Visible=True
End If
 
A

Andy Cole

Raul

If your form displays a record set then you will need to add similar code
to the Form's OnCurrent event to flip the visiblity while navigating the
record set.

HTH

Andy

Joe Fallon said:
Hint:

If Me![txtData]="" Then
Me![txtName].Visible=False
Else
Me![txtName].Visible=True
End If
--
Joe Fallon
Access MVP



Raul Sousa said:
I have a form with two fields (field A and field B).
I want field B to be visible only if field A has any
values.
I was thinking on Field B invisible and on an after
update Field A event to make it visible. Does any one
have a better idea?
The problem is that I do not know the code to make a
field in(visible), can some one give me an hint?

Thanks
 
A

Andy Cole

Raul

'Me' represents the Form or Report containing the code that is currently
being executed - its like an automatically provided variable referring to
the current instance of a Form/Report's class module - a bit like;

Dim Me as Form
Me = Forms!MyForm

You can use it to get to all the form's properties and controls collection
etc. (also saves a lot of typing!!). If you ever have multiple copies of
the same form, each form instance has its own version of Me and so will
*always* refer to the instance you're interested in.


When you delete a control's value, it may not be necessarily be equal to the
empty string ("") so you might want to use Nz(Me![FieldA],"") instead.
Another factor may be the where the code is being run from. In certain
control events for example, the .Value property (implicitly being used me
Me![FieldA]) may not have been updated but the .Text property will have.

HTH

Andy


Raul Sousa said:
I have just one more question.
What does Me! "mean"?

This hint works fine. The only situation is that when I
input a value on Field A Field B became visible, as
expected, but when I delete the value in field A field B
does not became invisible.

This is my code:
If Me![Field A] = "" Then
Me![Field B].Visible = False
Else
Me![ Field B].Visible = True
-----Original Message-----
Hint:

If Me![txtData]="" Then
Me![txtName].Visible=False
Else
Me![txtName].Visible=True
End If
--
Joe Fallon
Access MVP



Raul Sousa said:
I have a form with two fields (field A and field B).
I want field B to be visible only if field A has any
values.
I was thinking on Field B invisible and on an after
update Field A event to make it visible. Does any one
have a better idea?
The problem is that I do not know the code to make a
field in(visible), can some one give me an hint?

Thanks


.
 

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