|
-
Mar 11th, 2009, 12:28 PM
#1
Thread Starter
New Member
Problem sorting by alphabetical order...
Hello:
I've got a lists of risk ids that display in one box "strID" and I've created another box "strID1"to display the risk ids as well as the descriptions. I can't figure out how to display them in alphabetical order. The code is below:
Private Sub cmdProcess_Click()
Dim x, y As Integer
Dim cBox, cQuery, cQuery1 As String
Dim strID, strID1, strThreshhold As String, rs As dao.Recordset, sql As String
strID = ""
If Me.cboQuarter.Value <> "" And Me.cboYear.Value <> "" And Me.cboSite.Value <> "" And Me.cbothreshold.Value <> "" Then
If Trim(Me.cboSite.Value) = "All" Then
Me.cboSite.Value = ""
End If
cQuery = "quarter = '" & Trim(Me.cboQuarter.Value) & "' And year = " & Trim(Str(Me.cboYear.Value)) & " And Risk_ID like '" & Trim(Me.cboSite.Value) & "*'"
For x = 1 To 5
For y = 1 To 5
strID = ""
sql = "select risk_ID, risk_description from risks where " & cQuery & strThreshhold & " And Int(residual_consequence_score) =" & Trim(Str(y)) & " And Int(residual_likelihood_score) = " & Trim(Str(x))
Set rs = CurrentDb.OpenRecordset(sql)
cBox = "Risk" & Trim(Str(x)) & Trim(Str(y))
Me.Controls(cBox).Value = ""
Do Until rs.EOF
strID = strID & " " & rs("risk_id")
strID1 = strID1 & " " & rs("risk_id") & " - " & rs("risk_description") & vbCrLf '****Can anyone get this to display alphabetically****?
rs.MoveNext
Me.Controls(cBox).Value = strID
Loop
Next y
Next x
Me.Controls!RiskDesc = strID1
If Trim(Me.cboSite.Value) = "" Then
Me.cboSite.Value = "All"
End If
Me.cmdPrint.Enabled = True
Me.Refresh
Else
MsgBox ("Please select a value before clicking the Generate Chart button")
End If
Debug.Print sql
End Sub
Any help is appreciated. I'm a novice coder and using VB 6.5 and Access 2003.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|