Sort Order for combo box on form...

M

Mary A Perez

The form I'm working on for the user has a "Contract Name" combo box where
the user can choose a Contract Name, and I also have a "Contract Rate Sheet
Name" combo box where the user after choosing the Contract Name chooses the
Contract Rate Sheet Name associated only with that Contract Name.
The code is as such:
Private Sub cmbContractName_AfterUpdate()
Dim strSQL As String

If Nz(Me.cmbContractName, 0) <> 0 Then
strSQL = " Select ContractRateSheetNameId ,ContractRateSheetName "
strSQL = strSQL & " from tblContractRateSheetNames "
strSQL = strSQL & " where ContractId= " & Me.cmbContractName

With Me.cmbContractRateSheetName
.RowSource = strSQL
.Requery
End With
End If
End Sub

My question is that the user want the "Contract Rate Sheet Name" to be in
Alphabetical Order. How can I do this? I tried going to the
tblContractRateSheetNames" & sorting the ContractRateSheetName column in
ascending order, that didn't work, then I tried going to the row source query
& placing the sort order ascending in the ContractRateSheetName field, but
neither works.
Any suggestions?
 
D

Douglas J Steele

strSQL = " Select ContractRateSheetNameId ,ContractRateSheetName "
strSQL = strSQL & " from tblContractRateSheetNames "
strSQL = strSQL & " where ContractId= " & Me.cmbContractName
strSQL = strSQL & " order by ContractRateSheetName"
 
O

Ofer

Try

strSQL = " Select ContractRateSheetNameId ,ContractRateSheetName "
strSQL = strSQL & " from tblContractRateSheetNames "
strSQL = strSQL & " where ContractId= " & Me.cmbContractName
strSQL = strSQL & " Order By ContractRateSheetName"
 
M

Mary A Perez

Thank you!

Douglas J Steele said:
strSQL = " Select ContractRateSheetNameId ,ContractRateSheetName "
strSQL = strSQL & " from tblContractRateSheetNames "
strSQL = strSQL & " where ContractId= " & Me.cmbContractName
strSQL = strSQL & " order by ContractRateSheetName"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top