I have a form [nameform] which prompts a user for their name. This form remains open and I have a crosstab query that uses the field [nameform].[name] as a parameter. This parameter is in my design of the query as well as established in the parameters of the query as "Text". This query runs fine. I then base a report off of this crosstab query. This is where I have trouble.
The VBA code for my report is based on code that I took from a developers solution I downloaded for reports with dynamic column headings. I've used this code before on several reports and it works great. Unfortunately, these other reports are based on queries with no parameters. Here is what my code for my report looks like:
Dim dbsReport AS DAO.Database
Dim rstReport AS DAO.Recordset
Dim qdf AS QueryDef
Set dbsReport=CurrentDb
Set qdf=dbsReport.QueryDefs("[name of query]"
Set rstReport=qdf.OpenRecordset()
The debug error highlights the rstReport=qdf.OpenRecordset() line and states "too few parameters." From other threads, I think I need to put an SQL statement in the parentheses of the OpenRecordset statement; however, I have no idea what part of the SQL statement from my query and I've tried all kinds of syntax. This is my SQL from my query:
PARAMETERS [forms]![nameform]![name] Text 255;
TRANSFORM Sum(table.[field])AS[field]
SELECT table.field
FROM (table)INNER JOIN
ON(table.field)=
.(field)
WHERE (((table.field)=[forms]![nameform]![name]AND((table.field)Is Not Null)
GROUP BY table.field
PIVOT table.field IN (blah,blah,blah)
Any help with what actually should be placed in the parentheses and what should and shouldn't be in quotes would be greatly helpful. Sorry I'm not any better at VBA but, believe it or not, I'm learing.
The VBA code for my report is based on code that I took from a developers solution I downloaded for reports with dynamic column headings. I've used this code before on several reports and it works great. Unfortunately, these other reports are based on queries with no parameters. Here is what my code for my report looks like:
Dim dbsReport AS DAO.Database
Dim rstReport AS DAO.Recordset
Dim qdf AS QueryDef
Set dbsReport=CurrentDb
Set qdf=dbsReport.QueryDefs("[name of query]"
Set rstReport=qdf.OpenRecordset()
The debug error highlights the rstReport=qdf.OpenRecordset() line and states "too few parameters." From other threads, I think I need to put an SQL statement in the parentheses of the OpenRecordset statement; however, I have no idea what part of the SQL statement from my query and I've tried all kinds of syntax. This is my SQL from my query:
PARAMETERS [forms]![nameform]![name] Text 255;
TRANSFORM Sum(table.[field])AS[field]
SELECT table.field
FROM (table)INNER JOIN
WHERE (((table.field)=[forms]![nameform]![name]AND((table.field)Is Not Null)
GROUP BY table.field
PIVOT table.field IN (blah,blah,blah)
Any help with what actually should be placed in the parentheses and what should and shouldn't be in quotes would be greatly helpful. Sorry I'm not any better at VBA but, believe it or not, I'm learing.