I have a form (frmAdd) with a datalist (dlJobNo) on it that is bound to an access database using ADO. There is a cmdAddJobNo button on this form. This button opens frmAddJobNo that has a textbox txtAddJobNo. The user types into this box and then clicks the cmdAddJobNo button...
Private Sub cmdAddJobNo_Click()
On Error GoTo ErrLabel
Dim varx As Variant
'Set Provider
Set conn = New ADODB.Connection
conn.Provider = "Microsoft.JET.OLEDB.3.51"
'Open ps97.mdb as the Admin User
conn.Open "C:\_mfi\TP\ProjectServices\ps97.mdb", "admin", ""
'Load the recordset with data in Categories Table
Set rst = New ADODB.Recordset
rst.CursorType = adOpenKeyset
rst.LockType = adLockOptimistic
rst.Source = "tblJobNo"
rst.ActiveConnection = conn
rst.Open
rst.AddNew
rst.Fields("JobNo"
= txtAddJobNo.Text
rst.Update
rst.Requery
MsgBox ("Job Number added"
txtAddJobNo.Text = ""
rst.Close
conn.Close
frmAddJobNo.Hide
frmAdd.Show
Exit Sub
ErrLabel:
MsgBox Err.Description, vbInformation
End Sub
This works fine and updates the tblJobNo in ps97.mdb. I'd like, however, to sort the datalist (dlJobNo) on the frmAdd after the user adds more job numbers. How do I make the tblJobNo appear in alphabetical order when it populates the dlJobNo datalist?
Thank you for the help.
Private Sub cmdAddJobNo_Click()
On Error GoTo ErrLabel
Dim varx As Variant
'Set Provider
Set conn = New ADODB.Connection
conn.Provider = "Microsoft.JET.OLEDB.3.51"
'Open ps97.mdb as the Admin User
conn.Open "C:\_mfi\TP\ProjectServices\ps97.mdb", "admin", ""
'Load the recordset with data in Categories Table
Set rst = New ADODB.Recordset
rst.CursorType = adOpenKeyset
rst.LockType = adLockOptimistic
rst.Source = "tblJobNo"
rst.ActiveConnection = conn
rst.Open
rst.AddNew
rst.Fields("JobNo"
rst.Update
rst.Requery
MsgBox ("Job Number added"
txtAddJobNo.Text = ""
rst.Close
conn.Close
frmAddJobNo.Hide
frmAdd.Show
Exit Sub
ErrLabel:
MsgBox Err.Description, vbInformation
End Sub
This works fine and updates the tblJobNo in ps97.mdb. I'd like, however, to sort the datalist (dlJobNo) on the frmAdd after the user adds more job numbers. How do I make the tblJobNo appear in alphabetical order when it populates the dlJobNo datalist?
Thank you for the help.