Hi all,
I downloaded a search form from the forum a couple of weeks ago and I have just got around to setting it up on my database and it works really well. I have attached it below and recommend it to any others looking for a quick and simple Search function for their database.
I have however come across a problem that I cannot figure out and think it is to do with the changes I had to make to the code to suit my database. I cannot attach a copy of the database so will do my best to explain.
Originally, I had the "Search" text box searching for a Vehicle Registration number(AAA123) or a Fleet Number(123). I designed the form and table like the attached sample and it was working great. There is another field in my table with the vehicles driver and I was asked if I could set it up to search on that field too. As with the other query criteria, I added Like "*" & [Forms]![frmFleetList]![Search2] & "*" to the "Driver" field in the query. Using the text box "Search" still works and returns results as the text is entered however when I select the record in the list box I want to display, some of the records do not update the information in the fields below the list box and the error procedure below is activated.
Private Sub QuickSearch_AfterUpdate()
DoCmd.Requery
Me.RecordsetClone.FindFirst "[FLEET] = '" & Me![QuickSearch] & "'"
If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = Me.RecordsetClone.Bookmark
Else
MsgBox "Could not locate [" & Me![QuickSearch] & "]"
End If
End Sub
If anyone could tell my why they think this is happening or where I have gone wrong it would be appreciated.
This is a great search tool and as I said above, I recommend it to anyone looking for a search function.
Regards
Craig
I downloaded a search form from the forum a couple of weeks ago and I have just got around to setting it up on my database and it works really well. I have attached it below and recommend it to any others looking for a quick and simple Search function for their database.
I have however come across a problem that I cannot figure out and think it is to do with the changes I had to make to the code to suit my database. I cannot attach a copy of the database so will do my best to explain.
Originally, I had the "Search" text box searching for a Vehicle Registration number(AAA123) or a Fleet Number(123). I designed the form and table like the attached sample and it was working great. There is another field in my table with the vehicles driver and I was asked if I could set it up to search on that field too. As with the other query criteria, I added Like "*" & [Forms]![frmFleetList]![Search2] & "*" to the "Driver" field in the query. Using the text box "Search" still works and returns results as the text is entered however when I select the record in the list box I want to display, some of the records do not update the information in the fields below the list box and the error procedure below is activated.
Private Sub QuickSearch_AfterUpdate()
DoCmd.Requery
Me.RecordsetClone.FindFirst "[FLEET] = '" & Me![QuickSearch] & "'"
If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = Me.RecordsetClone.Bookmark
Else
MsgBox "Could not locate [" & Me![QuickSearch] & "]"
End If
End Sub
If anyone could tell my why they think this is happening or where I have gone wrong it would be appreciated.
This is a great search tool and as I said above, I recommend it to anyone looking for a search function.
Regards
Craig