1

Prompting for user input parameters in an Access query is fairly straight forward. Go to design view and under criteria, just put [Your Text:] -- and when the query runs the user is prompted for the field criteria.

Unfortunately when I try this with my Inner Joined Crosstab query I get the error:

The Microsoft Access engine does not recognize the '[Your Text:]' as a valid field name or expression.

I know the inner join crosstab still allows for criteria, as hardcorded criterion works.

To give you a better idea of what I'm looking at, here is the SQL code.

DOESN'T WORK:

SELECT *
FROM ([CrossTabQ1] 
INNER JOIN [CrossTabQ2] ON [CrossTabQ1].[Month] = [CrossTabQ2].[Month]) 
INNER JOIN [Query3] ON [CrossTabQ1].[Month] = [Query3].[Month]
WHERE ((([CrossTabQ1].[Month])= [Enter Month, in YYYY-MM Format:]))
ORDER BY [CrossTabQ1].[Month];

DOES WORK:

WHERE ((([CrossTabQ1].[Month])="2015-12"))
ORDER BY [CrossTabQ1].[Month];

Any tips regarding why I'm getting this error and how I can accept user input criterion would be greatly appreciated!

TMY
  • 471
  • 1
  • 7
  • 20

1 Answers1

1

Try:

PARAMETERS Enter_Month Text ( 255 );
SELECT *
FROM ([CrossTabQ1] 
INNER JOIN [CrossTabQ2] ON [CrossTabQ1].[Month] = [CrossTabQ2].[Month]) 
INNER JOIN [Query3] ON [CrossTabQ1].[Month] = [Query3].[Month]
WHERE ((([CrossTabQ1].[Month])=[Enter_Month]))
ORDER BY [CrossTabQ1].[Month];
Fadi
  • 3,302
  • 3
  • 18
  • 41
  • That gives me "Syntax error in query expression 'WHERE (((...remaining code'. Any suggestions? – TMY Jan 26 '16 at 15:26
  • 1
    Maybe PARAMETER's name not acceptable, I update it to simple name as I see it in my query SQL view and test it in ms access 2010, see this [question](http://stackoverflow.com/q/16568461/4039286) maybe help. – Fadi Jan 26 '16 at 16:19
  • 1
    This worked great, thank you @Fadi! For those that might stumble into this issue and want to use spaces and special characters, just add brackets "[ ]" around Enter_Month in the Parameters line. Ex. "PARAMETERS [Enter Month (YYYY-MM format)] Text (255); ... then WHERE... =[Enter Month (YYYY-MM format)]. All set! – TMY Jan 27 '16 at 13:36
  • @TMY, Thank You for these extra informations about `spaces and special characters`. – Fadi Jan 27 '16 at 23:27