Solved

ORDER BY in Cascading Combo Boxes in Access 2007

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

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…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

770 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