D
dave b via AccessMonster.com
I have a form where I collect varibles to run a report. One of the variables
is a list of product codes; they are stored in a table that is created when
the user opens the form. At first, the name of the table of product codes
was constant. I decided to create the table with a name using a timestamp
(tblProduct<hhmmss>), so that everytime the user opens the report form, they
are going to be using a new table. The table is deleted when the user exits
the table.
The report uses a simple query. At first I used a filter that was built
based on the variables selected. The code to build the filter is in a
separate module that is assigned when the report is opened. Since then, I've
read some of the threads on this site and realized that the where condition
would be a better choice. And I am also thinking of building the
filter/where in the form. What I need is to be able to build the filter or
where using a table name that will be a variable, and I'm assuming part of
the condition will be something like:
qryFillingReport!ProductID = tblProduct102536!ProductID
but where tblProduct102536 would be replaced by a varible that has the name
of the product code table assigned to it. Sample code would be helpful.
A second problem I'm having is that while testing, I used a hardcoded product
code and assigned it to the where condition of the DoCmd.OpenReport in the
form:
strReportWhere = "queries!qryFillingDetailReport!ProductID = 'AMP'"
DoCmd.OpenReport "rptFillingDetail", acViewPreview, , strReportWhere
What I'm getting is all records, when I expect to get just the record with
product codes of AMP.
is a list of product codes; they are stored in a table that is created when
the user opens the form. At first, the name of the table of product codes
was constant. I decided to create the table with a name using a timestamp
(tblProduct<hhmmss>), so that everytime the user opens the report form, they
are going to be using a new table. The table is deleted when the user exits
the table.
The report uses a simple query. At first I used a filter that was built
based on the variables selected. The code to build the filter is in a
separate module that is assigned when the report is opened. Since then, I've
read some of the threads on this site and realized that the where condition
would be a better choice. And I am also thinking of building the
filter/where in the form. What I need is to be able to build the filter or
where using a table name that will be a variable, and I'm assuming part of
the condition will be something like:
qryFillingReport!ProductID = tblProduct102536!ProductID
but where tblProduct102536 would be replaced by a varible that has the name
of the product code table assigned to it. Sample code would be helpful.
A second problem I'm having is that while testing, I used a hardcoded product
code and assigned it to the where condition of the DoCmd.OpenReport in the
form:
strReportWhere = "queries!qryFillingDetailReport!ProductID = 'AMP'"
DoCmd.OpenReport "rptFillingDetail", acViewPreview, , strReportWhere
What I'm getting is all records, when I expect to get just the record with
product codes of AMP.