jeffjohnson29
New member
- Local time
- Today, 17:13
- Joined
- Nov 9, 2017
- Messages
- 8
I am really new to building access databases and using vbs and I have watched the how to from steve bishop on how to create a keyword search using subforms but for some reason it does not work for me and I am unsure where my mistake is. I have been able to get the search to function inside the subform which is how I have it now. attached is a sample of my database. below is the code I used when the search box and button was outside the subform.
Private Sub btnSearch_Click()
Dim SQL As String
SQL = "SELECT [Asset Inventory].[Service Tag], [Asset Inventory].[Location Name], [Asset Inventory].Name, [Asset Inventory].[Asset Number], [Asset Inventory].[Computer Model] " _
& "FROM [Asset Inventory] " _
& "WHERE Name LIKE '*" & Me.txtTerm & "*' " _
& " OR [Service Tag] LIKE '*" & Me.txtTerm & "*' " _
& " OR [Asset Number] LIKE '*" & Me.txtTerm & "*' " _
& "ORDER BY [Asset Inventory].[Asset Number] "
Me.subSearch.Form.RecordSource = SQL
Me.subSearch.Form.Requery
End Sub
My ultimate goal is to be able to search in that sub form and then be able to click on the desired record and have it autofill the fields in the form that correlate to that record.
Any help would be appreciated thank you in advance.
Private Sub btnSearch_Click()
Dim SQL As String
SQL = "SELECT [Asset Inventory].[Service Tag], [Asset Inventory].[Location Name], [Asset Inventory].Name, [Asset Inventory].[Asset Number], [Asset Inventory].[Computer Model] " _
& "FROM [Asset Inventory] " _
& "WHERE Name LIKE '*" & Me.txtTerm & "*' " _
& " OR [Service Tag] LIKE '*" & Me.txtTerm & "*' " _
& " OR [Asset Number] LIKE '*" & Me.txtTerm & "*' " _
& "ORDER BY [Asset Inventory].[Asset Number] "
Me.subSearch.Form.RecordSource = SQL
Me.subSearch.Form.Requery
End Sub
My ultimate goal is to be able to search in that sub form and then be able to click on the desired record and have it autofill the fields in the form that correlate to that record.
Any help would be appreciated thank you in advance.
Attachments
Last edited: