If possible, change the type of the WeekNumber column to int or another integer type. If this is not yet possible, then use ORDER BY Cast(WeekNumber AS int)
.
And do not set the Sorted property of the combobox.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi Good People. I have a Combo Box on my Form that will not Sort Ascending or Descending, I load the Comb Box with Week Numbers From my SQL Database when the Form Loads. But when I click on the Combo Box (Dropped Down) The Numbers Are Not sorted Code And Picture Below. Can You Help Kind Regards Gary
Private Sub LoadCmbxWeekNumber()
SQL.ExecQuery("SELECT * FROM MultiRecords")
If SQL.RecordCount < 1 Then Exit Sub
If SQL.RecordCount > 0 Then
'Dim WN As Double = GetDouble(TxtWeekNumber.Text)
If String.IsNullOrEmpty(TxtDriverName.Text) Then
SQL.ExecQuery("SELECT DISTINCT WeekNumber FROM MultiRecords ORDER BY WeekNumber ASC")
For Each r As DataRow In SQL.SQLDT.Rows
CmbxWeekNumber.Items.Add(r("WeekNumber").ToString)
Next
ElseIf Not String.IsNullOrEmpty(TxtDriverName.Text) Then
SQL.AddParam("@DriverName", TxtDriverName.Text)
SQL.ExecQuery("SELECT WeekNumber WHERE DriverName=@DriverName ORDER BY WeekNumber ASC")
For Each r As DataRow In SQL.SQLDT.Rows
CmbxWeekNumber.Items.Add(r("CmbxWeekNumber").ToString)
Next
End If
End If
End Sub
If possible, change the type of the WeekNumber column to int or another integer type. If this is not yet possible, then use ORDER BY Cast(WeekNumber AS int)
.
And do not set the Sorted property of the combobox.