Variable Problem

  • Thread starter Thread starter Scott
  • Start date Start date
S

Scott

Hi-

I'm trying to write a fairly complex report with several sub-reports and I'm
running into problems. I have fields in a tables that I need to reference
in both the report and sub-reports, but the system says that it can't find
the field reference. The VB code is simple, I'm referring to the field as
either 'Me.variable' or Me!variable', and as I type the field is displayed
for me to pick from while programming, but yet the code error at this
statement. However, when I put the field on the report and set 'visible' to
true, the VB code works.

How can I get a field reference to work if the field isn't apart of the
report, but is apart of the table?

Scott
 
Scott said:
Hi-

I'm trying to write a fairly complex report with several sub-reports and I'm
running into problems. I have fields in a tables that I need to reference
in both the report and sub-reports, but the system says that it can't find
the field reference. The VB code is simple, I'm referring to the field as
either 'Me.variable' or Me!variable', and as I type the field is displayed
for me to pick from while programming, but yet the code error at this
statement. However, when I put the field on the report and set 'visible' to
true, the VB code works.

How can I get a field reference to work if the field isn't apart of the
report, but is apart of the table?

You shouldn't have to make it visible, but you're right that you will need to have a
control on the Report to reference the value in code. At least that has been my
experience. I have never had any trouble making these controls hidden though.
 
Scott said:
I can hide the field on the form and then make reference to it inVB as well.
But it seems strange why we can't reference the field in a table from a
report like we can reference a field from table in a form (does that make
sense?). I've got dozens of fields in a table that are not on the report
and I fear that hiding them will make editing the report a problem.

If you come across any solution, let me know if you can!

AFAIK, there is no solution other than what Rick said. It's
not that big a deal to add a small invisible textbox to the
report (I like the idea of setting the back color to red so
it's easily identifiable).

You don't actually need a separate text box for each field.
If you have more than one field you want to get to and the
report is really crowded, then you can reference several
fields in one control using an expression something like:
=f1 & f2 & f3

The reason that this is necessary for reports (and not for
forms) is that Access constructs it own internal query to
deal with such things as grouping and aggregate functions.
As a speed optimization, the internal query does not bother
pulling fields that are not referenced in a control.
 
Marshall

Thanks for the post! I'll give your suggestion a try.

Scott


Marshall Barton said:
Scott said:
I can hide the field on the form and then make reference to it inVB as well.
But it seems strange why we can't reference the field in a table from a
report like we can reference a field from table in a form (does that make
sense?). I've got dozens of fields in a table that are not on the report
and I fear that hiding them will make editing the report a problem.

If you come across any solution, let me know if you can!

AFAIK, there is no solution other than what Rick said. It's
not that big a deal to add a small invisible textbox to the
report (I like the idea of setting the back color to red so
it's easily identifiable).

You don't actually need a separate text box for each field.
If you have more than one field you want to get to and the
report is really crowded, then you can reference several
fields in one control using an expression something like:
=f1 & f2 & f3

The reason that this is necessary for reports (and not for
forms) is that Access constructs it own internal query to
deal with such things as grouping and aggregate functions.
As a speed optimization, the internal query does not bother
pulling fields that are not referenced in a control.
--
Marsh
MVP [MS Access]

need
to have a has
been my
though.
 
Back
Top