Just inherited an Access database which tracks clients and events, and issues invitations to active users. When selecting clients to be invited to events, a list is presented with the many thousands of names unsorted. We would like to have this list sorted by LastName, then by FirstName
I traced the source of the list back to this bit of VB code which I would like to modify so that clients are sorted. I'm sure it's just a simple addition to the code, but for the life of me I can't get it to work.
' initialize a string for the query
Dim strQuery As String
strQuery = "SELECT (s.Salutation & ' ' & c.FirstName & ' ' & c.LastName & IIf(t.Title Is Not Null,(', ' & t.Title),' ')) AS ClientName FROM (tblClient AS c LEFT JOIN qryTitleFilter AS t ON c.Title = t.TitleID) LEFT JOIN qrySalutationFilter AS s ON c.Salutation = s.SalutationID WHERE c.ClientID = " & intClientID & ";"
I have tried to tack on the ORDER BY element at the end in various ways but it doesn't want to work. When I do it returns an error and the VB debugger highlights the following line which is this:
' open the record set
Dim adoRs As New ADODB.Recordset
adoRs.Open strQuery, CurrentProject.Connection, adOpenStatic, adLockOptimistic, adCmdText
I hope I'm being clear here...I am really an advanced Access user, so please let me know if I've left any important information out of this post.
Thanks!
Stacy
I traced the source of the list back to this bit of VB code which I would like to modify so that clients are sorted. I'm sure it's just a simple addition to the code, but for the life of me I can't get it to work.
' initialize a string for the query
Dim strQuery As String
strQuery = "SELECT (s.Salutation & ' ' & c.FirstName & ' ' & c.LastName & IIf(t.Title Is Not Null,(', ' & t.Title),' ')) AS ClientName FROM (tblClient AS c LEFT JOIN qryTitleFilter AS t ON c.Title = t.TitleID) LEFT JOIN qrySalutationFilter AS s ON c.Salutation = s.SalutationID WHERE c.ClientID = " & intClientID & ";"
I have tried to tack on the ORDER BY element at the end in various ways but it doesn't want to work. When I do it returns an error and the VB debugger highlights the following line which is this:
' open the record set
Dim adoRs As New ADODB.Recordset
adoRs.Open strQuery, CurrentProject.Connection, adOpenStatic, adLockOptimistic, adCmdText
I hope I'm being clear here...I am really an advanced Access user, so please let me know if I've left any important information out of this post.
Thanks!
Stacy