ORDER BY in Cascading Combo Boxes in Access 2007

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
------------------------------------------------------------------------------------------------
gracie1972Asked:
Who is Participating?
 
Jim HornConnect With a Mentor Microsoft SQL Server Developer, Architect, and AuthorCommented:
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
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
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
 
gracie1972Author Commented:
Thank you, both features worked Awesome :-)
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Thanks for the grade.  Good luck with your project.  -Jim
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.