I have a query tha refers to some combos in a form. It is designed in order to give the user the possibility to choose some parameters and filter the data. When the user click a the runquery button a subform will display the resul of the query (stored). Everything works perfectly. Now what I would like to do is to give the possibility to the user to work with the records selected by the query.
The idea was to populate a recordset with the result of the query but I really cannot make the stored query working in a VBA module. I think I tried all the possible combinations of double and single quotes, but I came to a dead point: the message I get is this a type mismatch error(13):
here is the query:
strSql = "SELECT tbl_Person.Per_Name, tbl_Person.Per_LastName, tbl_Type.Typ_ID, tbl_Country.Cou_ID, tbl_Person.Per_ID FROM tbl_Country RIGHT JOIN (tbl_Type RIGHT JOIN tbl_Person ON tbl_Type.Typ_ID=tbl_Person.Per_Type) ON tbl_Country.Cou_ID=tbl_Person.Per_Country WHERE ((ISNULL(tbl_Type.[typ_ID]) AND '" & Forms!Form1!Cbo_Type.Value & "' = '" * "') OR tbl_Type.[typ_ID] Like '" & Forms!Form1!Cbo_Type.Value & "') AND ((ISNULL(tbl_Country.[Cou_ID]) AND '" & Forms!Form1!cbo_country.Value & "' = '" * "') OR tbl_Country.[cou_ID] Like '" & Forms!Form1!cbo_country.Value & "') AND ((ISNULL(tbl_Person.[per_name]) AND '" & Forms!Form1!cbo_Person.Value & "' = '" * "') OR tbl_Person.[per_name] Like '" & Forms!Form1!cbo_Person.Value & "');"
Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!
Or try our Ask An Expert service to answer any of your questions!