?
Solved

ORDER BY in Cascading Combo Boxes in Access 2007

Posted on 2013-01-18
4
Medium Priority
?
713 Views
Last Modified: 2013-01-18
Here is my Code for my cascading combo boxes in Access, all I want to do is sort by Project in my second combo box.  Order by is not working.....

----------------------------------------------------------------------------------------------
Private Sub ProjectType_AfterUpdate()

Me.Project.RowSource = " SELECT ProjectID,Project, ProjectTypeID" _
                       & " FROM tblProjects" _
                       & " WHERE ProjectTypeID=" & Me.ProjectType  
End Sub
------------------------------------------------------------------------------------------------
0
Comment
Question by:gracie1972
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 2000 total points
ID: 38794624
The below assumes ProjectTypeID is numeric.

Me.Project.RowSource = " SELECT ProjectID,Project, ProjectTypeID FROM tblProjects WHERE ProjectTypeID=" & Me.ProjectType  & " ORDER BY Project"

If it's a text...

Me.Project.RowSource = " SELECT ProjectID,Project, ProjectTypeID FROM tblProjects WHERE ProjectTypeID='" & Me.ProjectType  & "' ORDER BY Project"
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 38794637
Also, if the one combo box feeds another, you can be real slick and move the focus to the second one...

Me.Project.SetFocus
Me.Project.DropDown
0
 

Author Closing Comment

by:gracie1972
ID: 38794659
Thank you, both features worked Awesome :-)
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 38794665
Thanks for the grade.  Good luck with your project.  -Jim
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question