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 
ComboBox Rowsource
Abraham Breuer 
     
5 years ago
Hi!

I have set up a form with 2 Comboboxes 1- CustomerCombo 2- SalesRepCombo,

then used the after update event:

   Private Sub CustomerCombo_AfterUpdate()

      SalesRepCombo.RowSource = "SELECT SalesRepID, SalesRepFullName, FROM SalesRepCustomerQ" & _
                             " WHERE CustomerID=" & CustomerCombo & _
                             " ORDER BY SalesRepID ;"
  
   End Sub


if u have a look at the code you will see that the select statement is based on a query, the reason why I did so is: because my SalesReps are not directly related to the customers (see screenshot the relations),
to make it clear the customers are companies which have employees and sales reps are their employees, (and the database is an electric company who takes calls from companies so a company is for me a customer and when taking a call I need to keep track who of there employees contact us)  so I did not just put in in salesRepT the ID where they are employed because they might work at more then 1 company! therefore I built a separate table to make a one-to-many relation.

I built a query to put together the sales rep full name and the places where he works (which can be more than 1 place) so now I am able to use this query for my Combobox, but I want that the SalesRepCombo should be based on the CustomerCombo, but looks it does not work throwing out an error msg

Any solution?
Abraham Breuer OP  @Reply  
     
5 years ago

Abraham Breuer OP  @Reply  
     
5 years ago

Alex Hedley  @Reply  
           
5 years ago
SalesRepCombo.RowSource = "SELECT SalesRepID, SalesRepFullName, FROM SalesRepCustomerQ" & _
                             " WHERE CustomerID=" & CustomerCombo & _
                             " ORDER BY SalesRepID ;"


Comma (,) before the FROM
SalesRepFullName, FROM
Alex Hedley  @Reply  
           
5 years ago
I tend to set the ROWSOURCE to its own String variable
Then you can do Debug.Print(sql) or msgbox(sql) or status(sql) to see what the final SQL statement is
That way you can copy it into a new Query and try it there
Easier to spot mistakes then.
Abraham Breuer OP  @Reply  
     
5 years ago
Thanx Alex! yep that silly comma that wastes my time...
BTW am moving to the UK soon...!

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: 5/6/2026 5:40:49 AM. PLT: 1s