Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Sorting (Order By)

Status
Not open for further replies.

Steven547

Technical User
Sep 15, 2004
165
US
Still new to the VBA programming, but I have a question (probably really simple too...)

Why won't this code sort the list by priority level?

-----------------------------------------------------------

Private Sub Form_Current()

'Update Search Request ID Combo with current selection criteria
strRowSource = "SELECT TBLRequests.RequestID,Request "
strRowSource = strRowSource & "FROM TBLRequests "
strRowSource = strRowSource & "Where Completed = No"
strRowSource = strRowSource & "Order by PriorityLevel"

Me.cboSearchReqID.RowSource = strRowSource
Me.cboSearchReqID.Requery
-----------------------------------------------------------


Is it because of the: Me.cboSearchReqID.RowSource = strRowSource

End Sub
 
Your strRowSource will only take the value of the last line mentioned in coding, so you either need to put it in 1 string or strRowSource = strRowSource + "SELECT TBLRequests.RequestID,Request " etc.... with every line....


hope this helps
 
Anyway, lack of space before the ORDER BY clause

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I apologize, i'm not fully understanding what you're saying. I placed a space before the ORDER BY and no luck.

ItIsHardToProgram: When you say put it in 1 string or strRowSource = strRowSource + "SELECT TBLRequests.RequestID,Request " etc.... with every line...., That is where i'm getting confused.

 
And this ?
strRowSource = "SELECT RequestID,Request,PriorityLevel "
strRowSource = strRowSource & "FROM TBLRequests "
strRowSource = strRowSource & "WHERE Completed = No "
strRowSource = strRowSource & "ORDER BY PriorityLevel"

Amend the various column's properties of the combo to match this new source.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top