I have a continuous form, frmPoints, based on a query, qryPoints. The purpose of the form is to view, add, edit, or delete "points" given to students. The points can be either "Merits" or "Infractions" (the points are stored in tblPoints and the types in tblPointTypes). The form can be filtered in a number of ways using buttons in the header that run
I have a text field called Reasons with values that come from a table tblReasons. For every record in tblPoints (when merits or infractions are given), there is a corresponding Reason (ReasonID in tblPoints). In the design of this database, I've included some aggregate functions in the footer of each form for quick reference. There are separate reports for more detailed analysis. I'd like two controls in the footer of frmPoints that displays the most frequent Reason (or a list of reasons sorted by frequency) for Merits and Infractions, respectively, for however the form is currently filtered.
I have been unable to figure out how to do this despite several hours of searching and experimenting. I originally tried a text box with various expressions involving
I need the control to update whenever the form is filtered, for example, by class or grade. I'm not sure if there's a way to reference the form's recordset or add the form's filter in the row source of the listbox. Is there any way to solve this using the control properties window? Or would I need to use VBA? Any help would be greatly appreciated. I'm happy to provide additional information if this is not enough.
Warm regards,
Chris
DoCmd.RunCommand acCmdFilterMenu
on the click event.I have a text field called Reasons with values that come from a table tblReasons. For every record in tblPoints (when merits or infractions are given), there is a corresponding Reason (ReasonID in tblPoints). In the design of this database, I've included some aggregate functions in the footer of each form for quick reference. There are separate reports for more detailed analysis. I'd like two controls in the footer of frmPoints that displays the most frequent Reason (or a list of reasons sorted by frequency) for Merits and Infractions, respectively, for however the form is currently filtered.
I have been unable to figure out how to do this despite several hours of searching and experimenting. I originally tried a text box with various expressions involving
Iif
, Count
, Dcount
, Sum
, etc., but to no avail. I did find a way to count the frequencies of all field values using a query with 'Group By' and 'Count' (I made a link to the webpage where I found that method, but it was flagged as spam, so I've removed it). This led me to trying a list box instead, but if I use the query as the row source of a list box, it can only show the frequencies for the entire unfiltered table/query. Below is the SQL for the query that totals merit reasons:
SQL:
SELECT tblPointReasons.Reason, Count(tblPointReasons.Reason) AS CountOfReason, tblPointTypes.Type
FROM tblPointTypes INNER JOIN (tblPointReasons INNER JOIN qryPoints ON tblPointReasons.ID = qryPoints.ReasonID) ON tblPointTypes.ID = tblPointReasons.TypeID
GROUP BY tblPointReasons.Reason, tblPointTypes.Type
HAVING (((tblPointTypes.Type)="Merit"));
I need the control to update whenever the form is filtered, for example, by class or grade. I'm not sure if there's a way to reference the form's recordset or add the form's filter in the row source of the listbox. Is there any way to solve this using the control properties window? Or would I need to use VBA? Any help would be greatly appreciated. I'm happy to provide additional information if this is not enough.
Warm regards,
Chris
Last edited: