J
JJ
Could any one please assist? OS=XP Prof SP2, Office 2003 Prof SP2.
I have a form with a few option buttons. When they choose one specific
option it loads a Combobox2 where they select Author Initials e.g.
"AD". Once selected I open a query in an Access Database to list all
documents for the Author AD. However, the list is sorted ascending. I
want it descending. My query (in design view) is sorted descending.
See SQL data herewith:
SELECT DocNameSearch.DocName, DocNameSearch.DocComment
FROM DocNameSearch
ORDER BY DocNameSearch.DocName DESC;
I list my code for linking the info to my Combobox3. Please let me
know whether I can insert an .indexsort or whatever in the code. Any
help will be greatly appreciated.
Thanx
Private Sub ComboBox2_AfterUpdate()
ComboBox3.Clear
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim NoOfRecords As Long
' Open the database
Set db = OpenDatabase(MastPath & "ADNDatabase.mdb")
Set DocNamedb = OpenDatabase(MastPath & "ADNDatabase.mdb")
With db
On Error Resume Next
.QueryDefs.Delete "DocNameSearch"
ClientDetails = ComboBox2.Text
' Retrieve the recordset
Set rs = db.OpenRecordset("SELECT DocName, DocComment FROM
DocNamePath WHERE DocName LIKE '" & ClientDetails & "*'")
Set qdfNew = .CreateQueryDef("DocNameSearch", SQLQuery)
Set Docnamesearch = DocNamedb.OpenRecordset("DocNameSearchSorted")
With rs
.MoveLast
NoOfRecords = .RecordCount
.MoveFirst
End With
' Set the number of Columns = number of Fields in recordset
ComboBox3.ColumnCount = rs.Fields.Count
ComboBox3.Column = rs.GetRows(NoOfRecords)
' Cleanup
rs.Close
db.Close
Docnamesearch.Close
DocNamedb.Close
Set rs = Nothing
Set db = Nothing
End With
End Sub
I have a form with a few option buttons. When they choose one specific
option it loads a Combobox2 where they select Author Initials e.g.
"AD". Once selected I open a query in an Access Database to list all
documents for the Author AD. However, the list is sorted ascending. I
want it descending. My query (in design view) is sorted descending.
See SQL data herewith:
SELECT DocNameSearch.DocName, DocNameSearch.DocComment
FROM DocNameSearch
ORDER BY DocNameSearch.DocName DESC;
I list my code for linking the info to my Combobox3. Please let me
know whether I can insert an .indexsort or whatever in the code. Any
help will be greatly appreciated.
Thanx
Private Sub ComboBox2_AfterUpdate()
ComboBox3.Clear
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim NoOfRecords As Long
' Open the database
Set db = OpenDatabase(MastPath & "ADNDatabase.mdb")
Set DocNamedb = OpenDatabase(MastPath & "ADNDatabase.mdb")
With db
On Error Resume Next
.QueryDefs.Delete "DocNameSearch"
ClientDetails = ComboBox2.Text
' Retrieve the recordset
Set rs = db.OpenRecordset("SELECT DocName, DocComment FROM
DocNamePath WHERE DocName LIKE '" & ClientDetails & "*'")
Set qdfNew = .CreateQueryDef("DocNameSearch", SQLQuery)
Set Docnamesearch = DocNamedb.OpenRecordset("DocNameSearchSorted")
With rs
.MoveLast
NoOfRecords = .RecordCount
.MoveFirst
End With
' Set the number of Columns = number of Fields in recordset
ComboBox3.ColumnCount = rs.Fields.Count
ComboBox3.Column = rs.GetRows(NoOfRecords)
' Cleanup
rs.Close
db.Close
Docnamesearch.Close
DocNamedb.Close
Set rs = Nothing
Set db = Nothing
End With
End Sub