Dear Patti:
Not this makes it a lot clearer.
You can move the controls on a form vertically by changing the Top
property of each control (and don't forget the label) when the Current
Event fires. The code would have to calculate this by looking at the
values in the columns that might be null and using a Choose function
to determine the Top value desired:
Me.MyControl.Top = Choose(IIf(IsNull(Me!Column1), 0, 1) +
IIf(IsNull(Me!Column2), 0, 1) , 217, 308, 390)
If the amount each column may move up is constant, something simpler
suggests itself:
Me.MyControl.Top = IIf(IsNull(Me!Column1), 0, 1 +
IIf(IsNull(Me!Column2), 0, 1) * 90 + 217
Here, the position of the Top of the control is 217 when all the
"possibly null" columns above it are null, but it moces down 90 for
each one that is not null.
Here, the Top of the control is 217, 308, or 390, depending on whether
either or both of the RecordSource columns Column1 or Column2 are
null, thus moving this control up one or two "notches" if those
controls disappear. You also need to set the visible property of the
controls that may disappear:
Me.MyControl.Visible = Not IsNull(Me!Column1)
Me.MyLabel.Visible = Not IsNull(Me!Column1)
On a report where you want to do this there will be a lot more work
required. I assume you will want the report to show more than one row
of data, right? But not in columns, rather vertical again.
We have only found this can be done by putting a bound control in
every position where it could occur and then controlling which ones
print. Having the information for the following row of data then
"move up" becomes a problem. The alternative might be to work the
query so it provides both the label and data, something like this:
SELECT UniqueKey, 1 AS Seq, "Label1" AS Label, Column1 AS Value
FROM YourTable
UNION ALL
SELECT UniqueKey, 2 AS Seq, "Label2" AS Label, Column2 AS Value
FROM YourTable
WHERE Column2 IS NOT NULL
UNION ALL
SELECT UniqueKey, 3 AS Seq, "Label3" AS Label, Column3 AS Value
FROM YourTable
WHERE Column3 IS NOT NULL
The UniqueKey needs to be one or more columns that uniquely identify
and sort the original rows in the query to be printed. Be sure to
Group and Sort the report by this (these) column(s) plus the Seq
column. The report can just show the Label and Value from the query
above. You should give your own values for the "Label#" literals and
the actual column and table name.
Please let me know how you get along with this.
Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts
Dear Patti:
By "hide" what do you mean? And by "blank" what do you mean? Do you
want an entire column in the datasheet of the query to disappear?
Is a "blank" field one that is NULL? Your code seems to indicate that
is what you mean.
So, what do you mean "hide"? Are you viewing multiple rows or just
one? If you are viewing multiple rows in columnar format, and some of
the values in a column are NULL and others are not, surely you cannot
"hide" the whole column without hiding values that are not NULL.
Perhaps if you specify how you "hide the blank fields with VB in a
form or report" this would make more sense.
Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts
On 29 Dec 2003 08:09:39 -0800, (e-mail address removed) (Patti) wrote:
I need to run a query that will (in the results) hide all blank
fields.
I have tried Expr:IIf[FiledOne] is not null, [FieldOne]). This does
not work.
Any suggestions??
I can hide the blank fields with VB in a form or the report, but I
don't know if I can or how to use VB in a query.
Thank you
Patti
Tom
The table will only ever pull one record at a time. So I need to hide
(not show) these fields in the query results. The fields are NULL.
There are 200+ fields in the table, and I only need to show the fields
that have informaiton in them. The table is set where the Job# is the
primary key and this is what you must enter to pull the needed
information. I have tried the IIf statement as above and a nested IIf
statement as well. I am just learning VB so I am really not that good
at it. In the form, and the report the blank fields do not show,
however I cannot get the the fields with the informaiton to move up to
fill in the blank spaces (on the computer screen) from where the Null
records are hidden. Again any help given will be GREATLY appreciated.
Thank you
Patti
(I am so happy I found this site)