I have created a form that allows the user to search a sales table with the option to choose 1) a sales representative and 2) a car type matching any portion of the inputted text. For example, you can choose "Joe Smith" as your salesman and type "mus" in the search box and all sales by Joe Smith selling a Mustang or a Mustafa (if such a goofy name for a car existed) would return.
The problem I am running into is with the subform on the form, which is supposed to display the results of the query. The code (below) instructs the subform to requery but it doesn't seem to be working.
Expand|Select|Wrap|Line Numbers
- Private Sub Command9_Click()
- Dim db As Database
- Dim qdf As QueryDef
- Dim strsql As String
- Set db = CurrentDb
- strsql = "SELECT [sales_rep], [sale_id], [automobile], [sale_price]" & _
- "FROM automobile_sales " & _
- "WHERE [automobile] Like '*' & '" & Me.automobile_search & "' & '*' AND [sales_rep]=[Forms]![Sale_Search]![associate];"
- db.QueryDefs.Delete "tmp_qry"
- Set qdf = db.CreateQueryDef("tmp_qry", strsql)
- me.sale_search_subform.requery
- End Sub
Thank you very much in advance!