Hello all, I am trying to create a search form with the following code:
Dim stDocName As String
Dim stLinkCriteria As String
Dim strFilter As String
If (fraKeywordType = 1) Then 'Family name
stDocName = "frmSAHSearchResults"
strFilter = "[SAHCarerLastName]='" & Me.txtSearchText.Value & "'"
ElseIf (fraKeywordType = 2) Then ' street address
stDocName = "frmSAHSearchResults"
strFilter = "[AddressStreet]='" & Me.txtSearchText.Value & "'"
ElseIf (fraKeywordType = 3) Then ' postcode
stDocName = "frmSAHSearchResults"
strFilter = "[AddressPostcode]='" & Me.txtSearchText.Value & "'"
End If
DoCmd.OpenForm stDocName, , strFilter, stLinkCriteria
I have a form frmSearch on which the user selects the type of keyword being entered e.g name or address and then enters the search text in a text box. when the search button is clicked, the frmSearchResults opens with the results. frmSearchResults in uses a list box underpinned by a query to list the results.
I am trying to get the query to accept the criteria selected from the frmSearch. Rightnow, it recognises one criteria when I put in the criteria colum in the query builder but doesnt recognise the others.
How do I make the query to use the appropriate criteria per time??
many thanks
TY
Dim stDocName As String
Dim stLinkCriteria As String
Dim strFilter As String
If (fraKeywordType = 1) Then 'Family name
stDocName = "frmSAHSearchResults"
strFilter = "[SAHCarerLastName]='" & Me.txtSearchText.Value & "'"
ElseIf (fraKeywordType = 2) Then ' street address
stDocName = "frmSAHSearchResults"
strFilter = "[AddressStreet]='" & Me.txtSearchText.Value & "'"
ElseIf (fraKeywordType = 3) Then ' postcode
stDocName = "frmSAHSearchResults"
strFilter = "[AddressPostcode]='" & Me.txtSearchText.Value & "'"
End If
DoCmd.OpenForm stDocName, , strFilter, stLinkCriteria
I have a form frmSearch on which the user selects the type of keyword being entered e.g name or address and then enters the search text in a text box. when the search button is clicked, the frmSearchResults opens with the results. frmSearchResults in uses a list box underpinned by a query to list the results.
I am trying to get the query to accept the criteria selected from the frmSearch. Rightnow, it recognises one criteria when I put in the criteria colum in the query builder but doesnt recognise the others.
How do I make the query to use the appropriate criteria per time??
many thanks
TY