Create charts/Subreports based on a listbox selection

DWayne

Registered User.
Local time
Today, 00:32
Joined
Feb 12, 2009
Messages
14
I'm sure this is not in any way an overly advanced procedure, but this is the situation. My Access skills are by no means advanced, but I do know a bit of VBA and have a cursory knowledge of SQL (I can read and understand it, but I could not write it from scratch -- so jealous of you kids who can).

Background
I have a personal financial accounts database, which lists 10 different financial accounts. The database has forms which allow me to record different activities (purchases, withdrawals, transactions, deposits).

Goal
The startup form will have the account holder's name and a listbox next to it that shows the account names (for simplicity's sake, let's say "Checking" "Savings" and "Cash").

Once an account is clicked on, I would like to show a subreport in the form based on the listbox selection, basically all transactions on that account in the last 10 days.

I also want to show a graph which displays my purchase types (my "purchases" table has a field for types of purchases, for simplicity, let's say "Food" "Transportation" and "Entertainment") in a pie chart.

Question
1) How do I make the form show nothing until a selection is chosen from the listbox, and then generate both the subreport and chart when I choose one of the accounts.

2) Where and how do I direct the chart/subreport to read that listbox selection on the form and create the corresponding parameter to create the chart/subreport?

Example

I start up the database, and up pops the startup form, with nothing on its face but my name and a listbox that shows the accounts "Checking", "Savings" and "Cash".

I click on "Checking", and on the left side of the form, there appears a 10 day activity report of all Checking account transactions. Then, on the right side of the form, there is a pie chart that displays the purchase types of the full account's history.

In both cases, the only parameter is the account.

Conclusion

I'm pretty sure this does not necessitate the use of a macro. I know this will involve using "Control Source", right?

I can fill out the details of it, but if anyone can either explain it, or give me directions on how to create a general simplified version of this, I'd appreciate it.
 
This was a surprisingly easy solution. I just swam around in Access and figured it out after some time. It involves (1) establishing the criteria on the chart's Row Source and (2) creating a macro for the event On Click.

1) Go to the chart's properties, under Data / Row Source, and enter the query builder. Under the fields that you want to show, in the criteria box, create an expression builder. You want the listbox in the form [Forms]![qryStartupForm]![AccountList] = [Queries]![qryAccountActivities]![AccountID]

2) Go to the Listbox's properties, under Event, On Click, select Macro Builder, and choose Requery. The control name is your report/chart (in my case, qryAccountActivities).

This kind of process can make a startup form look incredibly professional, and very efficient. Instead of having to look at every account altogether, you can select and choose what you want to see. Also, you just have to build one massive activity query, and the charts can have that built in information

My next project is creating an option button that lets you choose either to display reports/graphs based on currency or accounts.

Lotsa fun, this Access stuff.
 

Users who are viewing this thread

Back
Top Bottom