I have a crosstab query that pulls summarized data from another query. In the first query I had used an expression like Between #03/01/04# and #03/31/04# to select the records that I wanted. The crosstab query worked fine. Then I wanted to get the date parameters from off of a form so it could be easily changed. So I modified my first query’s expression to Between [forms]![frmSalesTaxItems]![SalesTaxBeginDate] And [forms]![frmSalesTaxItems]![SalesTaxEndDate]. These dates are actually stored in a table. The first query runs fine. But the crosstab query won’t run. I tried making a new crosstab query and I get this error message: The Microsoft Jet database engine does not recognize ‘[forms]![frmSalesTaxItems]![SalesTaxBeginDate]’ as a valid field name or expression. Is there a problem using an expression in a query that is the source for a crosstab? Is there a work around?
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
fields in crosstab query (A2000 SR-1)
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » fields in crosstab query (A2000 SR-1)
- This topic has 25 replies, 6 voices, and was last updated 21 years ago.
Viewing 3 reply threadsAuthorReplies-
WSSwood
AskWoody Lounger -
Gwb
AskWoody LoungerApril 2, 2004 at 2:59 pm #808937 -
WSSwood
AskWoody Lounger -
Gwb
AskWoody LoungerApril 2, 2004 at 3:25 pm #808947The form frmSalesTaxItems has two text boxes on it for the beginning and ending dates; their control source is a table. At your suggestion, I tried the Between [Beginning date] And [Ending Date] but I get the same type of error message. If there is no other work around, I’ve thought about having the first query make a temporary table, then basing the crosstab off of a table instead of a query. Then deleting the table.
-
-
WSSwood
AskWoody Lounger
-
-
Gwb
AskWoody LoungerApril 2, 2004 at 2:59 pm #808938
-
-
WSSwood
AskWoody Lounger -
WSMarkD
AskWoody LoungerApril 2, 2004 at 3:32 pm #808948Recommend review this MSKB article & see if it applies:
ACC2000: Error When Running Crosstab Query with a Parameter
Brief excerpt:
[indent]
CAUSE
A crosstab query dynamically generates column names. Therefore, Microsoft Access cannot tell whether [XXX] or a form reference is referring to a parameter or to a column name until after the query is bound.RESOLUTION
To avoid this error, define [XXX] as an explicit parameter by adding it to the Query Parameters dialog box. To do so, follow these steps:
[/indent]
See article for full details.HTH
-
WSSwood
AskWoody LoungerApril 2, 2004 at 3:34 pm #808952 -
WSSwood
AskWoody LoungerApril 2, 2004 at 3:34 pm #808953 -
WSjimbeard
AskWoody LoungerApril 7, 2004 at 5:30 pm #811502I’ve had no luck with the workaround suggested in the knowledge base.
[Feel free to skip this paragraph:] My query is summarizing numbers of patients seen at various sites between specified dates who have certain impediments to learning. Each impediment is a boolean field in the patient’s record in the Patients table. To get all the sites to appear (not just the few who’ve had at least one patient for EVERY impediment in the time range), the queries have to be done in two steps: First, for each impediment, a query counts the number of affected persons at each site in the time range, and throws in a constant field that names the impediment being looked for. Then a union query combines all these results.
Using a PivotTable view in Access 2002, the results of the union query can be viewed as desired (the rows are the sites, the columns are the various impediments, and the values are the counts of affected patients)
But the crosstab query can’t be formulated in either Access 2002 or Access 2000. I’ve tried making the start date and end date into typed parameters in the underlying queries (where they actually ARE parameters), but then I get the error:
Invalid bracketing of name . (Error 3126)
The specified name either cannot have brackets around it or the brackets are mismatched. Check your entry to make sure the brackets are properly matched, and then try the operation again.The brackets ARE correct, though, and the ones around the terms that don’t have spaces in them are added by Access itself, i.e., in
“>=[forms]![Get Dates Dialog]![txtStartDate]”, the brackets around “forms” and “txtStartDate” are added by Access.The fact the the PivotTable view works just fine, and the Crosstab doesn’t, indicates to me that the Crosstab machinery is just defective.
Jim Beard
-
WSHansV
AskWoody LoungerApril 7, 2004 at 6:46 pm #811570Specifying the parameters explicitly should work, but it’s hard to say what causes your problems without seeing the database. Perhaos you could post a stripped-down copy:
- Make a copy of the database and work with that.
- Remove all database objects (tables, queries, forms, reports, macros and modules) that are not relevant to the problem.
- In the remaining table(s), remove most records – leave only the minimum number necessary to demonstrate the problem.
- Remove or modify data of a confidential nature.
- Do a compact and repair (Tools/Database Utilities).
- Make a zip file containing the database; it should be below 100KB.
- If you have difficulties getting the zip file below 100 KB, save the database in Access 97 format and then zip it. (Of course, this only helps if you’re using Access 2000 or later.)
- Attach the zip file to a reply.
[/list]
-
WSjimbeard
AskWoody LoungerApril 7, 2004 at 11:45 pm #811791It’s not so easy to get a 12-MB, 2-file data base down to a 100K zip file! Anyway, I think the attached database still functions and illustrates the problem.
To demonstrate, open form “Get Dates Dialog”, enter starting and ending dates (June, 2002 or later) and choose OK to execute the code and hide the form. Then try to get the results of the query, “Limitations (all) by date and site” into a crosstab form without first copying them into a temporary table.
Jim
-
WSHansV
AskWoody Lounger -
WSjimbeard
AskWoody LoungerApril 9, 2004 at 5:28 am #812465Hans,
Your crosstab query in the example version works perfectly, as you know. However, when I take the specimen that I posted and attempt to make declared parameters of Forms![Get Dates Dialog]!txtStartDate and the end date, I get the bracketing error I described in my earlier post. I’m using Access 2002 SP3. In fact, if I take YOUR copy of the parameterized query, edit | cut one of the parameters, close the parameters box, open it again, paste the text back in and give it a date/time type, I then get the error! (All this is done in “Design View”.)
By examining the query in SQL format before and after re-entering the parameter info, I finally found the error that my copy of Access makes. It puts brackets around the entire parameter expression, as follows: “[[forms]![Get Dates Dialog]![txtStartDate]]” Notice the double opening brackets. But then it can’t parse the resulting expression, and the version it quotes in the error message does indeed have a bracketing mismatch. (I hadn’t previously noticed the that the version that the error message quotes me does have a bracket-count error, though the expression in the parameter window does not.) Your version, which works fine, does not have that extra set of surrounding brackets in its SQL. If I edit them out of the SQL that my copy of Access creates, I can get my query to work.
I wonder if it’s worth trying to explain the bug to Microsoft.
Jim
-
WScharlotte
AskWoody LoungerApril 9, 2004 at 5:44 am #812467Consider it a “feature”. In versions of Access prior to 2000, the query engine would accept parameters without the brackets or with brackets around only some parts of the form reference. The query engine changed quite a bit with Access 2000, and those parameters that had partial brackets got reinterpreted as something besides a valid form reference. One of the more annoying things about 2000 is that you have to manually fix those parameters or you run into the problem you encountered. If you fix the bracketing and resave the query, it should work properly thereafter. Note that it only occurs if you had *some* brackets in the parameter. If you had none, the conversion takes care of it, but if you had brackets around the name of the form but not the other parts of the reference, you wind up with the situation you have here.
-
WSjimbeard
AskWoody Lounger -
WSjimbeard
AskWoody Lounger -
WScharlotte
AskWoody LoungerApril 9, 2004 at 5:44 am #812468Consider it a “feature”. In versions of Access prior to 2000, the query engine would accept parameters without the brackets or with brackets around only some parts of the form reference. The query engine changed quite a bit with Access 2000, and those parameters that had partial brackets got reinterpreted as something besides a valid form reference. One of the more annoying things about 2000 is that you have to manually fix those parameters or you run into the problem you encountered. If you fix the bracketing and resave the query, it should work properly thereafter. Note that it only occurs if you had *some* brackets in the parameter. If you had none, the conversion takes care of it, but if you had brackets around the name of the form but not the other parts of the reference, you wind up with the situation you have here.
-
WSjimbeard
AskWoody LoungerApril 9, 2004 at 5:28 am #812466Hans,
Your crosstab query in the example version works perfectly, as you know. However, when I take the specimen that I posted and attempt to make declared parameters of Forms![Get Dates Dialog]!txtStartDate and the end date, I get the bracketing error I described in my earlier post. I’m using Access 2002 SP3. In fact, if I take YOUR copy of the parameterized query, edit | cut one of the parameters, close the parameters box, open it again, paste the text back in and give it a date/time type, I then get the error! (All this is done in “Design View”.)
By examining the query in SQL format before and after re-entering the parameter info, I finally found the error that my copy of Access makes. It puts brackets around the entire parameter expression, as follows: “[[forms]![Get Dates Dialog]![txtStartDate]]” Notice the double opening brackets. But then it can’t parse the resulting expression, and the version it quotes in the error message does indeed have a bracketing mismatch. (I hadn’t previously noticed the that the version that the error message quotes me does have a bracket-count error, though the expression in the parameter window does not.) Your version, which works fine, does not have that extra set of surrounding brackets in its SQL. If I edit them out of the SQL that my copy of Access creates, I can get my query to work.
I wonder if it’s worth trying to explain the bug to Microsoft.
Jim
-
WSHansV
AskWoody Lounger
-
-
WSjimbeard
AskWoody LoungerApril 7, 2004 at 11:45 pm #811792It’s not so easy to get a 12-MB, 2-file data base down to a 100K zip file! Anyway, I think the attached database still functions and illustrates the problem.
To demonstrate, open form “Get Dates Dialog”, enter starting and ending dates (June, 2002 or later) and choose OK to execute the code and hide the form. Then try to get the results of the query, “Limitations (all) by date and site” into a crosstab form without first copying them into a temporary table.
Jim
-
-
WSHansV
AskWoody LoungerApril 7, 2004 at 6:46 pm #811571Specifying the parameters explicitly should work, but it’s hard to say what causes your problems without seeing the database. Perhaos you could post a stripped-down copy:
- Make a copy of the database and work with that.
- Remove all database objects (tables, queries, forms, reports, macros and modules) that are not relevant to the problem.
- In the remaining table(s), remove most records – leave only the minimum number necessary to demonstrate the problem.
- Remove or modify data of a confidential nature.
- Do a compact and repair (Tools/Database Utilities).
- Make a zip file containing the database; it should be below 100KB.
- If you have difficulties getting the zip file below 100 KB, save the database in Access 97 format and then zip it. (Of course, this only helps if you’re using Access 2000 or later.)
- Attach the zip file to a reply.
[/list]
-
-
WSjimbeard
AskWoody LoungerApril 7, 2004 at 5:30 pm #811503I’ve had no luck with the workaround suggested in the knowledge base.
[Feel free to skip this paragraph:] My query is summarizing numbers of patients seen at various sites between specified dates who have certain impediments to learning. Each impediment is a boolean field in the patient’s record in the Patients table. To get all the sites to appear (not just the few who’ve had at least one patient for EVERY impediment in the time range), the queries have to be done in two steps: First, for each impediment, a query counts the number of affected persons at each site in the time range, and throws in a constant field that names the impediment being looked for. Then a union query combines all these results.
Using a PivotTable view in Access 2002, the results of the union query can be viewed as desired (the rows are the sites, the columns are the various impediments, and the values are the counts of affected patients)
But the crosstab query can’t be formulated in either Access 2002 or Access 2000. I’ve tried making the start date and end date into typed parameters in the underlying queries (where they actually ARE parameters), but then I get the error:
Invalid bracketing of name . (Error 3126)
The specified name either cannot have brackets around it or the brackets are mismatched. Check your entry to make sure the brackets are properly matched, and then try the operation again.The brackets ARE correct, though, and the ones around the terms that don’t have spaces in them are added by Access itself, i.e., in
“>=[forms]![Get Dates Dialog]![txtStartDate]”, the brackets around “forms” and “txtStartDate” are added by Access.The fact the the PivotTable view works just fine, and the Crosstab doesn’t, indicates to me that the Crosstab machinery is just defective.
Jim Beard
-
-
WSMarkD
AskWoody LoungerApril 2, 2004 at 3:32 pm #808949Recommend review this MSKB article & see if it applies:
ACC2000: Error When Running Crosstab Query with a Parameter
Brief excerpt:
[indent]
CAUSE
A crosstab query dynamically generates column names. Therefore, Microsoft Access cannot tell whether [XXX] or a form reference is referring to a parameter or to a column name until after the query is bound.RESOLUTION
To avoid this error, define [XXX] as an explicit parameter by adding it to the Query Parameters dialog box. To do so, follow these steps:
[/indent]
See article for full details.HTH
Viewing 3 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Firefox 137
by
Charlie
35 minutes ago -
Whisky, a popular Wine frontend for Mac gamers, is no more
by
Alex5723
2 hours, 35 minutes ago -
Windows 11 Insider Preview build 26120.3863 (24H2) released to BETA
by
joep517
2 hours, 47 minutes ago -
Windows 11 Insider Preview build 26200.5551 released to DEV
by
joep517
2 hours, 49 minutes ago -
New Windows 11 PC setup — can I start over in the middle to set up a local id?
by
ctRanger
2 hours, 54 minutes ago -
Windows 11 Insider Preview Build 26100.3902 (24H2) released to Release Preview
by
joep517
6 hours, 21 minutes ago -
Oracle kinda-sorta tells customers it was pwned
by
Nibbled To Death By Ducks
12 hours, 23 minutes ago -
Global data centers (AI) are driving a big increase in electricity demand
by
Kathy Stevens
22 hours, 43 minutes ago -
Office apps read-only for family members
by
b
1 day, 1 hour ago -
Defunct domain for Microsoft account
by
CWBillow
22 hours, 11 minutes ago -
24H2??
by
CWBillow
12 hours, 22 minutes ago -
W11 23H2 April Updates threw ‘class not registered’
by
WindowsPersister
6 hours, 36 minutes ago -
Master patch listing for April 8th, 2025
by
Susan Bradley
6 hours, 50 minutes ago -
TotalAV safety warning popup
by
Theodore Nicholson
3 hours, 12 minutes ago -
two pages side by side land scape
by
marc
2 days, 23 hours ago -
Deleting obsolete OneNote notebooks
by
afillat
3 days, 1 hour ago -
Word/Outlook 2024 vs Dragon Professional 16
by
Kathy Stevens
2 days, 4 hours ago -
Security Essentials or Defender?
by
MalcolmP
2 days, 6 hours ago -
April 2025 updates out
by
Susan Bradley
1 hour, 52 minutes ago -
Framework to stop selling some PCs in the US due to new tariffs
by
Alex5723
2 days ago -
WARNING about Nvidia driver version 572.83 and 4000/5000 series cards
by
Bob99
1 day, 14 hours ago -
Creating an Index in Word 365
by
CWBillow
2 days, 16 hours ago -
Coming at Word 365 and Table of Contents
by
CWBillow
1 day, 4 hours ago -
Windows 11 Insider Preview Build 22635.5170 (23H2) released to BETA
by
joep517
3 days, 20 hours ago -
Has the Microsoft Account Sharing Problem Been Fixed?
by
jknauth
3 days, 23 hours ago -
W11 24H2 – Susan Bradley
by
G Pickerell
4 days, 1 hour ago -
7 tips to get the most out of Windows 11
by
Alex5723
3 days, 23 hours ago -
Using Office apps with non-Microsoft cloud services
by
Peter Deegan
1 hour, 15 minutes ago -
I installed Windows 11 24H2
by
Will Fastie
1 day, 23 hours ago -
NotifyIcons — Put that System tray to work!
by
Deanna McElveen
4 days, 4 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.