English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I have been working on a database and put some combo boxes in, and want to have a counter tally the selections. How can I tally the selections, and implement microsoft access to graph the results in a pie chart? ~~Shawn

2006-09-06 10:41:26 · 2 answers · asked by Shawn R 1 in Computers & Internet Programming & Design

2 answers

Are your combo boxes linked to table/query data or an entered list?

If linked, you can add a field for the count of the selections to the table or the table underlying the query and write code that will increment each time the box is updated. While at this point, you may want to consider how and when to reset the counter.

Code should be written in the combo box's After update event. You get there by displaying the properties of the combo box and choosing the Event tab. In the After Update, click on the elipse button (...) Choose code builder and Ok.

While prototyping this, I find it is best to not put anything in the combo box's Control Source, but have the row source be the table. You will need a field for the choice made and a field that shows the count on the form, but they can be hidden, if you want. Here is the code I used that accumulated the counts. Remember this is in the after update event code of the combo box:

Private Sub fChoice_AfterUpdate()
DoCmd.GoToControl "Choice"
DoCmd.FindRecord Me.fChoice
DoCmd.GoToControl "countofchoice"
Me.CountofChoice = Me.CountofChoice + 1
End Sub

I named my combo box fChoice (Form's choice)
My data that is selected is in Choice in Table1
the counters are kept in the field called CountofChoice

Then on your form you do: Insert Chart, Drag a box open on the form, choose the table and the count field and the field you choose, in my case, countofChoice and Choice.

My example has Choice in the X Axis and sum of count of choice in the Data box. It only updates when the form is opened, but it shows the chart of the data before it changes, you may want to pop up a separate form after the update of the combo box, to have the newly opened form reflect the data after your most recent update.

2006-09-09 05:35:51 · answer #1 · answered by Ken C. 6 · 0 0

link the database as a table in Access

2006-09-06 12:22:00 · answer #2 · answered by sethsdadiam 5 · 0 0

fedest.com, questions and answers