Count total schools by stage (1 Viewer)

mohamedmatter

Registered User.
Local time
Today, 04:59
Joined
Oct 25, 2015
Messages
112
I want the total number of schools by stage. When the stage is changed, the number of schools is updated
I insert attach
sample school database
 

Attachments

  • school.accdb
    544 KB · Views: 67

isladogs

MVP / VIP
Local time
Today, 12:59
Joined
Jan 14, 2017
Messages
18,240
Use a totals query. Group by Stage, Count by School

Code:
SELECT Schooltbl.Stage, Count(Schooltbl.SchoolName) AS CountByStage
FROM Schooltbl
GROUP BY Schooltbl.Stage;
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:59
Joined
Sep 21, 2011
Messages
14,319
I want the total number of schools by stage. When the stage is changed, the number of schools is updated
I insert attach
sample school database
You have not even bothered to make an attempt? :(
 

mohamedmatter

Registered User.
Local time
Today, 04:59
Joined
Oct 25, 2015
Messages
112
Use a totals query. Group by Stage, Count by School

Code:
SELECT Schooltbl.Stage, Count(Schooltbl.SchoolName) AS CountByStage
FROM Schooltbl
GROUP BY Schooltbl.Stage;
thanks but i like counter in form by event help me
 

mike60smart

Registered User.
Local time
Today, 12:59
Joined
Aug 6, 2017
Messages
1,913

Attachments

  • Schools.PNG
    Schools.PNG
    9.2 KB · Views: 50

Gasman

Enthusiastic Amateur
Local time
Today, 12:59
Joined
Sep 21, 2011
Messages
14,319
Recalc, Refresh the form?
Never sure which TBH, :( so just experiment and try and learn something for yourself?
 

isladogs

MVP / VIP
Local time
Today, 12:59
Joined
Jan 14, 2017
Messages
18,240
I've no idea what you mean but you can display the results of the query in a subform.
If the data changes, just requery the subform to get the new values.
Time you tried for yourself
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:59
Joined
Sep 21, 2011
Messages
14,319
I've no idea what you mean but you can display the results of the query in a subform.
If the data changes, just requery the subform to get the new values.
Time you tried for yourself
Colin,
I opened the DB with bypass as you never know what they might contain. :(
So initially never saw the form, which must be a test version anyway?
O/P has a form with three controls for each of the stages.

I suggested a DCount() against your query.
So, if that form somehow added another stage to the table, what would you use to update the DCounts in the controls? :(
 

isladogs

MVP / VIP
Local time
Today, 12:59
Joined
Jan 14, 2017
Messages
18,240
If you want to use DCount, then no need for the query. Just base it on the table.

However, I wouldn't use DCount precisely because another stage such as Tertiary might get added at some point.
I would scrap those 3 controls and just display the results in a subform
 

mike60smart

Registered User.
Local time
Today, 12:59
Joined
Aug 6, 2017
Messages
1,913
how move value to form
You can create a Form in Continuous View based on your Table.

On this Form in the header you can create a Command Button which would open a Form based
on Colin's Totals Query. This Form would be a PopUp Form.

It would then give you the following Result when you click the View Totals Button
 

Attachments

  • School Totals.PNG
    School Totals.PNG
    41.4 KB · Views: 65

Gasman

Enthusiastic Amateur
Local time
Today, 12:59
Joined
Sep 21, 2011
Messages
14,319
If you want to use DCount, then no need for the query. Just base it on the table.

However, I wouldn't use DCount precisely because another stage such as Tertiary might get added at some point.
I would scrap those 3 controls and just display the results in a subform
Fair point. :)
 

mohamedmatter

Registered User.
Local time
Today, 04:59
Joined
Oct 25, 2015
Messages
112
I've no idea what you mean but you can display the results of the query in a subform.
If the data changes, just requery the subform to get the new values.
Time you tried for yourself
I've no idea what you mean but you can display the results of the query in a subform.
If the data changes, just requery the subform to get the new values.
Time you tried for yourself
I found a solution, but I encountered a simple problem, please help. It is when the stage is changed, the values are not changed after the stage is updated. I have attached the rule after the modification
 

Attachments

  • school v2.accdb
    768 KB · Views: 67

Gasman

Enthusiastic Amateur
Local time
Today, 12:59
Joined
Sep 21, 2011
Messages
14,319
You seriously are not going to try and do any of the work yourself are you?. :mad:

I am out of this thread.
 

isladogs

MVP / VIP
Local time
Today, 12:59
Joined
Jan 14, 2017
Messages
18,240
This is my last post as well

If you must use DCount then you need to ensure the changed data is saved before recalculating.
Add the line Me.Dirty =False at the start of the Stage after update event
 

Users who are viewing this thread

Top Bottom