Crosstab query not recognize input date text box (1 Viewer)

Sokkheng

Member
Local time
Today, 23:34
Joined
Jul 12, 2023
Messages
34
I have create Crosstab query that source is get from the first query that have input Start Date and End Date get from my input form. when i run the crosstab query it show message : The Microsoft database engine does not recognize '[Forms]![frmNavigationForm].[Form]![txtStartDate]' as a valid filed name or expression.
But for the other select query is ok, it does't running only crosstab query.
What is my mistake in crosstab query?
Thanks for help
 

jdraw

Super Moderator
Staff member
Local time
Today, 12:34
Joined
Jan 23, 2006
Messages
15,379
Check the links in the Similar Threads at the bottom of the page.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:34
Joined
Oct 29, 2018
Messages
21,474
You probably have to declare the parameter in your crosstab query (at least, if not in both).
 

ebs17

Well-known member
Local time
Today, 18:34
Joined
Feb 7, 2020
Messages
1,946
Form references in queries are always a bit problematic because Jet itself does not recognize objects such as Access forms. In some cases, Access resolves the content of a form control when passing the query to Jet, and Jet can do something with the substituted value.
However, in some cases (crosstab queries, parameters in subqueries, passing the query to DAO) this does not work. However, these internal reprocessings are not consistently implemented, the developer then has to get by and act without "Pampers".

There are several ways to pass parameters to queries. In a simple case, try using Eval in the query:
Code:
Forms.frmNavigationForm.Form.txtStartDate
=>
Eval("Forms.frmNavigationForm.Form.txtStartDate")
In the expression I removed the stupid superfluous brackets. Brackets used should have a meaning, which is not the case here.

Like I said, if that's not enough, there are other options.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 12:34
Joined
Feb 19, 2002
Messages
43,275
Setting the parameter in the crosstab should solve the problem but always remember when using dates from unbound controls as parameters to set the format of the control to a date format so that the expression engine recognizes that you intend for the data to be a date.
 

Users who are viewing this thread

Top Bottom