Okay, Alison
If this is a read-only display, and you want to combine fields to save
space, you could set the ControlSource of a text box to:
=[Address1] & " " & [Address2] & " " & [Address3] & " " & [Country]
That should work provided you make sure the Name of this text box is not the
same as any field name (e.g. it cannot be called Address1.)
I should be clear that setting the Visible property of the text boxes will
not give you any more space on the form, i.e. they don't shrink like text
boxes on reports do. Since you are producing read-only results anyway, you
might find it easier to show the users a report rather than a form,
especially if you want the typical address panel read out. In the report,
you can set the Can Shrink property of Address2 etc to Yes, and the lower
boxes will close up (provided there is nothing else on the same line
preventing them from shrinking.)
If you want to set the Visibility of the controls in the Current event
procedure of the form, you would write your VBA code like this:
Private Sub Form_Current()
Me.[Address1].Visible = Not IsNull(Me.[Address1].Visible)
Me.[Address2].Visible = Not IsNull(Me.[Address2].Visible)
End Sub
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Reply to group, rather than allenbrowne at mvps dot org.
Alison said:
Thanks Allen,
The table is a list of companies, with address, telephone, website etc.
The
fields that are often null are things like address3 (not all addresses
have a
3rd line) and country (I am UK and if they are UK too it is left blank)
It is form view. Users will not be updating fields in the table via this
form. When you talk about the 'current event', I take it you mean use VBA
to
run when the form displays data - and have it looking at every field
checking
whether it is null. I do not have any VBA writing experience - can you
advise
on what code I should use?
Is there not another way to do this? My form contents seem quite simple
(its
essentially a list of names and addresses) so I can't believe other people
have not come across it.