I have a make table query in MS Access.
I want a variable in this query to change based on an array value.
For some reason the .SQL Replace statement is not changing the value, even though when I debug and hover over the "x" array value it is there.
My code is:
If it would help to see my entire sql statement let me know.
If you have any suggestions to change how this is written let me know.
Thanks
I want a variable in this query to change based on an array value.
For some reason the .SQL Replace statement is not changing the value, even though when I debug and hover over the "x" array value it is there.
My code is:
Code:
Set qdf = CurrentDb.QueryDefs("i_qry_446_1")
With qdf
qdfOLD = .SQL
Debug.Print .SQL
.SQL = Replace(.SQL, "(STPID.CNTY_CD)='01'", "(STPID.CNTY_CD)= " & "'" & x & "'")
Debug.Print .SQL
'create the table
DoCmd.SetWarnings False
DoCmd.OpenQuery "i_qry_446_1"
DoCmd.Close
DoCmd.SetWarnings True
DoCmd.OpenQuery "i_qry_446"
DoCmd.Close
'export report 446
.SQL = qdfOLD ' Reset SQL to old setting
End With '446
If it would help to see my entire sql statement let me know.
If you have any suggestions to change how this is written let me know.
Thanks