Solved

ORDER BY in Cascading Combo Boxes in Access 2007

Posted on 2013-01-18
4
660 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
  • 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

706 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now