Hi,
I am more or less a beginner in Access. In my db, I have a search form with two input criteria (cboYear and txtInput) that populate a hidden text box (txtSearchString). The search results are displayed in a listbox (lstSummary) based on a query (qrySearch). The OnChange events allow updated results on each keystroke. The user selects the year of the search and then inputs text. The criteria in each field of qrySearch includes:
Like "*" & [Forms]![frmSearch]![txtSearchString] & "*"
This worked great for the first 2 or 3 years. However, as the years go by (I built this in ’06), it is increasingly cumbersome to manually search each year. I am hoping to find a fix that won’t require a total do-over like building a filter. If I want the search results to include matches from all years, is there a way for the search to happen with nothing in cboYear? In other words, it would search all years. Below is the relevant code. Thank you for your help.
Private Sub cboYear_Change()
Dim vSearchString As String
vSearchString = cboYear.Text
txtSearchString.Value = vSearchString
Me![Summary].Requery
End Sub
Private Sub txtInput_Change()
Dim vSearchString As String
vSearchString = txtInput.Text
txtSearchString.Value = vSearchString
Me![Summary].Requery
End Sub
Private Sub txtSearchString_Change()
Dim vSearchString As String
vSearchString = txtInput.Text & cboYear.Text
txtSearchString.Value = vSearchString
Me![lstSummary].Requery
End Sub
I am more or less a beginner in Access. In my db, I have a search form with two input criteria (cboYear and txtInput) that populate a hidden text box (txtSearchString). The search results are displayed in a listbox (lstSummary) based on a query (qrySearch). The OnChange events allow updated results on each keystroke. The user selects the year of the search and then inputs text. The criteria in each field of qrySearch includes:
Like "*" & [Forms]![frmSearch]![txtSearchString] & "*"
This worked great for the first 2 or 3 years. However, as the years go by (I built this in ’06), it is increasingly cumbersome to manually search each year. I am hoping to find a fix that won’t require a total do-over like building a filter. If I want the search results to include matches from all years, is there a way for the search to happen with nothing in cboYear? In other words, it would search all years. Below is the relevant code. Thank you for your help.
Private Sub cboYear_Change()
Dim vSearchString As String
vSearchString = cboYear.Text
txtSearchString.Value = vSearchString
Me![Summary].Requery
End Sub
Private Sub txtInput_Change()
Dim vSearchString As String
vSearchString = txtInput.Text
txtSearchString.Value = vSearchString
Me![Summary].Requery
End Sub
Private Sub txtSearchString_Change()
Dim vSearchString As String
vSearchString = txtInput.Text & cboYear.Text
txtSearchString.Value = vSearchString
Me![lstSummary].Requery
End Sub