I have a make-table query based on several other tables together with user input, and it works well. However, I don't think I can't use the query as it is. I think I need to create the same SQL text in VBA and add various WHERE values which the user creates by selecting values on a form.
The query includes an IIF clause to format two fields, but the SQL text from the query always fails at the VBA command "DoCmd.RunSQL (strSQL) with the run-time error above. I realise this is an Access SQL error not VBA.
The two fields are parts of a UK map reference for biological wildlife sites and consist of two letters and between two and ten numbers. Sometimes the site has been entered with no map reference and I use the IIF function to detect this. Here is the code from the query:
IIf(IsNull([Site].[Map_ref_letters])," ",[Site].[Map_ref_letters] & " " & Mid$([Site].[map_ref_numbers],1,5) & "/" & Mid$([Site].[map_ref_numbers],6,5)) AS [Map ref],
My VBA code is the same except that the spaces and forward slash inserted into the Map ref field have doubled quotes, e.g. ""/""
The query includes an IIF clause to format two fields, but the SQL text from the query always fails at the VBA command "DoCmd.RunSQL (strSQL) with the run-time error above. I realise this is an Access SQL error not VBA.
The two fields are parts of a UK map reference for biological wildlife sites and consist of two letters and between two and ten numbers. Sometimes the site has been entered with no map reference and I use the IIF function to detect this. Here is the code from the query:
IIf(IsNull([Site].[Map_ref_letters])," ",[Site].[Map_ref_letters] & " " & Mid$([Site].[map_ref_numbers],1,5) & "/" & Mid$([Site].[map_ref_numbers],6,5)) AS [Map ref],
My VBA code is the same except that the spaces and forward slash inserted into the Map ref field have doubled quotes, e.g. ""/""