Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > TechHelp > Directory > Access > Cascading Combo Boxes < Loan Payments | Vehicle Maintenance >
Back to Cascading Combo Boxes    Comments List
Upload Images   @Reply   Bookmark    Link   Email  
Select If Only One
Samantha Waterman 
     
14 months ago
Hello! I feel like this is probably a simple yes or no question that I just seemed to have missed the concept of or just can't seem to grasp - but is there a way to have the combo box automatically display one city if there isn't another option? Like if Houston was the ONLY city for TX in the video's example database, is there a way for it to just automatically display Houston without having to select the combo box and drop down to select JUST Houston?

Appreciate all the help you guys give, thank you so much! ^_^
Adam Schwanz  @Reply  
            
14 months ago
Sure, if nothing else just use VBA in the after update event of the state field.

If DCOUNT("*","Table","State=""" & ComboBox & """")=1 Then
CityField=DLOOKUP("City","Table","State=""" & ComboBox & """")
End If
Sami Shamma  @Reply  
             
14 months ago
Adam  
Elegant solution.
Kevin Yip  @Reply  
     
14 months ago
A combo box's ListCount property stores the number of items in the combo box.  So you can check if it is one, and if it is, retrieve the combo box's first item, which is stored in the ItemData(n) property, where n = 0 for the first item.  And if ListCount doesn't equal to one, be sure nothing is stored in the combo box by assigning null to it.  E.g.:

     If Me.Combo1.ListCount = 1 Then Me.Combo1 = Me.Combo1.ItemData(0) Else Me.Combo1 = Null

The most likely place to put this code is right after the combo box is requeried, assuming you have a cascading combo setup.
Richard Rost  @Reply  
          
14 months ago
So many ways to do everything in Microsoft Access. I love it!

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Cascading Combo Boxes.
 

 
 
 

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 2025 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/23/2025 2:06:21 PM. PLT: 1s