snippetMinor
Using a Parameter Query to generate Charts in MS Access Reports
Viewed 0 times
reportsquerygenerateusingaccesschartsparameter
Problem
I am using Microsoft Access 2007 and I have a query which looks something like this;
Now, this query works fine if I open the query and then enter the appropriate 'Identifier' value in the form that pops up. However, I would like to then use this query to generate a chart in a report that lists all of the studies. ie. The report will be made of 1 page per record, and each page will contain 1 chart, which shows the above data plotted as a line chart.
However, if I pop a chart in and use the wizard to create the chart, when I get to the stage where I would like to assign a fiend from the current record in the report to a value in the chart, I am unable to assign a report variable to the parameter I described above 'Identifier'. Now, normally, I would build the query to pull down all of the data, and then assign a 'filter' on that data I guess using the Chart Wizard. However, as I have a sub-query, this isn't going to work in this case.
What I believe I'm looking for, is a way of assigning the parameter 'Identifier' from the current record parameters in a multi-record report.
PARAMETERS Identifier TEXT(255);
SELECT
DateDiff('h', (SELECT Min(SampleDateTime) FROM Specimen WHERE UserID=[Identifier]), SampleDateTime) AS ElapsedTime, Specimen.ValueA
FROM Specimen
WHERE Specimen.UserID=[Identifier]
ORDER BY Specimen.SampleDateTimeNow, this query works fine if I open the query and then enter the appropriate 'Identifier' value in the form that pops up. However, I would like to then use this query to generate a chart in a report that lists all of the studies. ie. The report will be made of 1 page per record, and each page will contain 1 chart, which shows the above data plotted as a line chart.
However, if I pop a chart in and use the wizard to create the chart, when I get to the stage where I would like to assign a fiend from the current record in the report to a value in the chart, I am unable to assign a report variable to the parameter I described above 'Identifier'. Now, normally, I would build the query to pull down all of the data, and then assign a 'filter' on that data I guess using the Chart Wizard. However, as I have a sub-query, this isn't going to work in this case.
What I believe I'm looking for, is a way of assigning the parameter 'Identifier' from the current record parameters in a multi-record report.
Solution
You have have to try something a little loopy, such as the following:
Reports have a property called Tag
Open the Report in Design View
Open the Property Sheet and Select the 'Other' Tab
The Tag property is on the bottom of the list
You can access that Tag as follows:
Simply replace the
That way, if you open the query, you will still be prompted to input the UserID
When you open the Report, set
On the property sheet, Click
Now put that setting in (say the UserID is from a form):
Give it a Try !!!
Reports have a property called Tag
Open the Report in Design View
Open the Property Sheet and Select the 'Other' Tab
The Tag property is on the bottom of the list
You can access that Tag as follows:
Reports("Report Name").TagSimply replace the
[Identifier] with either Reports("Report Name").Tag or Me.TagThat way, if you open the query, you will still be prompted to input the UserID
When you open the Report, set
Me.Tag to whatever number you want. How to you set it in the first place ?On the property sheet, Click
Event Tab. In the OnLoad Event, click the three dots (ellipses). Menu pop ups. Click Code Builder. VBA opens on with :Private Sub Report_Load()
End SubNow put that setting in (say the UserID is from a form):
Private Sub Report_Load()
Me.Tag = Forms("Form Name")("Field Name")
End SubGive it a Try !!!
Code Snippets
Reports("Report Name").TagPrivate Sub Report_Load()
End SubPrivate Sub Report_Load()
Me.Tag = Forms("Form Name")("Field Name")
End SubContext
StackExchange Database Administrators Q#1881, answer score: 3
Revisions (0)
No revisions yet.