views:

166

answers:

1

Is there a way to reference a form's combo/text box within the query like a select query?

I usually use something like this in a select query's criteria:

like forms!frmMain.qTitleofSomething&* (access adds the brackets for me)

but this does not work in a crosstab query?? which i just found out. is there a way to accomplish the same kind of parameter control without setting up multiple crosstabs?

and as always, thanks!

+1  A: 

You need to add a parameter to the query if you wish to reference a form You can do this by right-clicking in the query design window or by typing it into the SQL view. You should end up with something on the lines of:

PARAMETERS [Forms]![frmA]![Field1] Short;
TRANSFORM Count(tblA.ID) AS CountOfID
SELECT tblA.Field2, Count(tblA.ID) AS [Total Of ID]
FROM tblA
WHERE tblA.Field1=[Forms]![frmA]![Field1]
GROUP BY tblA.Field2
PIVOT tblA.Field1;

Short refers to the data type of the field. The types are included in a drop down list available from right-clicking in the query design window and selecting Parameters.

Remou
thanks very much for this! i was pulling my hair out and you just saved me a lot of extra before and after queries!! thanks Remou!!
Justin