Solved

ORDER BY in Cascading Combo Boxes in Access 2007

Posted on 2013-01-18
4
706 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 65

Accepted Solution

by:
Jim Horn earned 500 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 65

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 65

Expert Comment

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

737 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