Control source "Version" works, "=[version]" does not

  • Thread starter Thread starter Bruce Musgrove
  • Start date Start date
B

Bruce Musgrove

The text box name is VersionTxt
The field name in the table is Version, and it is a text field

On the report if I set the controlsource property of VersionTxt to
"version", it works . If I set it to "=[version]" (as if I plan to
concatenate it) I get a #error displayed in the field

Help. Version is not a reserved word. There is not any other field /
control on the report ccalled Version. What could cause this?
 
In some circumstances,
=[fieldname]
fails unless there is a (hidden) control named "fieldname" on the report
somewhere.

This only happens with reports (never forms), and the issue seems to be
caused by how Access optimizes reports. The report retrieves a
forward-scrolling recordset (snapshot) that is grouped and sorted using the
entries you place in the Sorting And Grouping Dialog. But Access does not
merely generate a higher-level query stacked on top of the report's
RecordSource. Instead it intelligently examines what fields you are actually
using on the report, by examining the fields named in the ControlSource of
each control, and it generates an optimized query that fetches just those
fields grouped and sorted as it needs for its forward scrolling recordset.

In this process, it sometimes excludes fields that are part of an expression
in the Control Source. I have not been able to nail this down exactly, but
anecdotally it seems to recognise the fields that were present when the
report was created, and have problems with fields that were added to the
RecordSource afterwards.

Whatever is actually going on behind the scenes, the reality is that
sometimes you must place a hidden control on the report in order to get
Access to fetch the field if you want to refer to that field as part of an
expression in the control source of another control.

While that's not a watertight explanation, hopefully it's enough to help
preserve your sanity. :-)
 
Bruce said:
The text box name is VersionTxt
The field name in the table is Version, and it is a text field

On the report if I set the controlsource property of VersionTxt to
"version", it works . If I set it to "=[version]" (as if I plan to
concatenate it) I get a #error displayed in the field

Help. Version is not a reserved word. There is not any other field /
control on the report ccalled Version. What could cause this?


Well, Version is a reserved word. It's a property of the
Applcation object that returns the version of Access.

I don't know if that's causing the #Error. Most often that
eoor is because the text box has the same name as a field in
the expression.
 
Can you point me to a online resource that show it is a reserved word? That
is the first thing I looked for and according toMS's own site it is not
http://support.microsoft.com/default.aspx?scid=kb;en-us;286335




Marshall Barton said:
Bruce said:
The text box name is VersionTxt
The field name in the table is Version, and it is a text field

On the report if I set the controlsource property of VersionTxt to
"version", it works . If I set it to "=[version]" (as if I plan to
concatenate it) I get a #error displayed in the field

Help. Version is not a reserved word. There is not any other field /
control on the report ccalled Version. What could cause this?


Well, Version is a reserved word. It's a property of the
Applcation object that returns the version of Access.

I don't know if that's causing the #Error. Most often that
eoor is because the text box has the same name as a field in
the expression.
 
The compilation of that kind of list is subject to the human
error just like anything else. The simple check is to just
type:
?Version
into the Debug/Immediate window.

To really be safe for "reserved" words, a general guideline
is to never use a real word for anything you create.
--
Marsh
MVP [MS Access]


Bruce said:
Can you point me to a online resource that show it is a reserved word? That
is the first thing I looked for and according toMS's own site it is not
http://support.microsoft.com/default.aspx?scid=kb;en-us;286335


Bruce said:
The text box name is VersionTxt
The field name in the table is Version, and it is a text field

On the report if I set the controlsource property of VersionTxt to
"version", it works . If I set it to "=[version]" (as if I plan to
concatenate it) I get a #error displayed in the field

Help. Version is not a reserved word. There is not any other field /
control on the report ccalled Version. What could cause this?


Well, Version is a reserved word. It's a property of the
Applcation object that returns the version of Access.

I don't know if that's causing the #Error. Most often that
eoor is because the text box has the same name as a field in
the expression.
 
Back
Top