Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Count Records    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Count Records Tech Help
Donald Blackwell 
        
2 years ago
Just thought I'd share an alternative to the VBA solution for the State Combo box on the Customer List form in the Extended Cut. This is a solution I've used before because I am still learning the VBA side of Access so I've always done everything with either Macros or Queries, and quite frankly, Macros are a PITA when you need to use them in multiple places or if you just want to change something if you are doing a lot with a single macro.

Anywho, the following solution uses neither VBA or Macros:

1. In StateQ, Add a column "StateCt: Count(*)" and set the "Totals" for that column to "Expression"
Viewing the query, you'll now see the count for each state (not null) next to the state

2. Then switch to "SQL" View and before the SQL the Query Editor created add:

SELECT "{ALL}" as State, count([CustomerID]) as StateCt
FROM CustomerT
Having State Is Not Null

UNION ALL

After that leave the query provided by the Query Editor (or clean it up and remove all the extra table name. and extra parenthesis if you have OCD, lol)

Save the query

Back in the form design, just make sure the rowsource of the StateCombo still points to StateQ. On the format tab of the properties box, just change the column count to 2 and add ";0;" to the column widths so it doesn't actually show the state count in the combo box.

Select the StateCount text box and change its source control to:
=[StateCombo].[column](1)

Save the form, close it, then reopen it. The State Combo should default to "{ALL}" with the correct State count in the box and the StateCount box automatically updates to whatever value is stored in StateCombo column 1 without any other coding.

Now, I fully admit this isn't necessarily simpler than the VBA solution, just sharing that it can be done. I've never noticed any performance hits but then none of the applications I've used it on have ever had more than a few hundred records. So I guess it's just a matter of preference if someone doesn't want to break into VBA.

As they say on Vulcan, "Infinite Diversity in Infinite Combinations".

Thanks for all the great videos! I've been teaching myself Access off and on since the late 90's but have never been a fan of video learning but I found one of your videos on Youtube a couple of months ago and finally changed my view of video training! Even though I've been using Access, having your videos helps fill in in a lot of places where I've often added way more queries or macros to accomplish something that could easily be completed if I would have just known better techniques. That's why I joined both your Access Learning Channel and the Tech Help Channel!

As a side note, you may be happy to hear, I've been doing some searches through Co-Pilot for some projects lately and probably 60 to 70% of the time one of your videos pops up as a recommended reference source.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Count Records.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 6/16/2026 3:30:46 PM. PLT: 1s