Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Developer Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Setting combo box values
Colin Hursell 
      
3 years ago
I have a form with a 2 column combo box on it (ID and SupplierName). If the supplier I want is not in the dropdown list as defined by the row source SQL statement, I open another form to add the new supplier details.  When I close that additional form I would like to set the combo box to display that newly entered supplier details automatically, rather than have to select them from the updated drop down list.  The .column property of the combo box is read only, so I can't just assign values to the columns.  If I try that, I get a 'Run time error 424: Object required' error message.  Does anyone know a way to do this or a cunning work around?
Kevin Robertson  @Reply  
          
3 years ago
Use the DMax function to get the ID of the supplier you just entered (it will be at the end of the table) Then set the Combo Box equal to that ID.
You could do something like this:

Dim ID as Long

ID = DMax("SupplierID", "SupplierT", "SupplierID=" & ID)
cboSupplier = ID
Colin Hursell OP  @Reply  
      
3 years ago
Hi Kevin,  Thanks so much for this - I would never have thought of using DMax on the underlying table to get the just entered data back.  I don't need the criteria parameter in the DMax statement (I don't think it would work?) and I need to requery the combo box before executing the 'cboSupplier = ID' line but this works fine!  I was using tempVars to remember the data entered on the popup form before closing it, but then didn't know how to assign the stored values to the combo box.  That's because the cboSupplier line escaped me as well - I don't find it intuitive.  When a value is assigned to the combo box like that, is it assigned to a particular column, or does it (as it seems to) somehow refer to a record primary key in the underlying table?

I use the SQL statement:

SELECT 0 AS SupplierID, "(Add New Supplier)" AS SupplierName, "A" AS SortOrder FROM tblSuppliers UNION SELECT SupplierID, SupplierName, "B" AS SortOrder FROM tblSuppliers WHERE SupplierName IS NOT NULL ORDER BY SortOrder, SupplierName

as the combo box row source.  That gives me a sorted list of Supplier Names with '(Add New Supplier)' at the top of the list.  When the user chooses an item from the list I use the combo box OnUpdate event to see if (Add New Supplier) was chosen and if it was I open up the secondary form.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer Forum.
 

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 12:28:35 PM. PLT: 1s