Hello Everyone:
I have an unbound form which the user populates with data that they want to find, and it opens another form with the results. For example, they would enter "Smith" and "Third" to find people named Smith with the address of "Third" Street.
How can I get the results to be sorted alphabetically? Here is an excerpt of the code I have, but there are many more fields that can be searched.
Private Sub OK_Click()
Me.Visible = False
Dim strWhere As String
strWhere = "1=1 "
If Not IsNull(Me.txtLastName) Then
strWhere = strWhere & " And ([Last_Name] Like '" & _
Me.txtLastName & "*' OR [Spouse_CommonLaw_Last_Name] Like '" & _
Me.txtLastName & "*') "
End If
If Not IsNull(Me.txtFirstName) Then
strWhere = strWhere & " And ([First_Name] Like '" & _
Me.txtFirstName & "*' OR [Spouse_CommonLaw_First_Name] Like '" & _
Me.txtFirstName & "*') "
End If
If Not IsNull(Me.txtStreetAddress) Then
strWhere = strWhere & " And [Street_Address]='" & _
Me.txtStreetAddress & "' "
End If
DoCmd.OpenForm "LkkpPeople", acNormal, , strWhere
DoCmd.Close acForm, "FrmFindPeopleEntryForm"
Dim strSQL As String
End Sub
Sophia
I have an unbound form which the user populates with data that they want to find, and it opens another form with the results. For example, they would enter "Smith" and "Third" to find people named Smith with the address of "Third" Street.
How can I get the results to be sorted alphabetically? Here is an excerpt of the code I have, but there are many more fields that can be searched.
Private Sub OK_Click()
Me.Visible = False
Dim strWhere As String
strWhere = "1=1 "
If Not IsNull(Me.txtLastName) Then
strWhere = strWhere & " And ([Last_Name] Like '" & _
Me.txtLastName & "*' OR [Spouse_CommonLaw_Last_Name] Like '" & _
Me.txtLastName & "*') "
End If
If Not IsNull(Me.txtFirstName) Then
strWhere = strWhere & " And ([First_Name] Like '" & _
Me.txtFirstName & "*' OR [Spouse_CommonLaw_First_Name] Like '" & _
Me.txtFirstName & "*') "
End If
If Not IsNull(Me.txtStreetAddress) Then
strWhere = strWhere & " And [Street_Address]='" & _
Me.txtStreetAddress & "' "
End If
DoCmd.OpenForm "LkkpPeople", acNormal, , strWhere
DoCmd.Close acForm, "FrmFindPeopleEntryForm"
Dim strSQL As String
End Sub
Sophia