I am trying to update one table with a value from another table using the code below.
The first statement works and gets the value from the first table. the value is displayed correctly in the msgbox.
The SQL does not work as it treats the variant as a runtime input variable and asks for the value of M4KUSD.
How do I use the variant in the SQL?
Dim M4KUSD As Variant
Dim SQL As String
M4KUSD = DLookup("[exrate]", "pub_ccyex", "[toccykey] = 'USD' ")
SQL = "Update tbCurrencyRatesTEST Set Rate = M4KUSD where [CUR] = 'USD' "
Msgbox(M4KUSD)
DoCmd.RunSQL SQL
The first statement works and gets the value from the first table. the value is displayed correctly in the msgbox.
The SQL does not work as it treats the variant as a runtime input variable and asks for the value of M4KUSD.
How do I use the variant in the SQL?
Dim M4KUSD As Variant
Dim SQL As String
M4KUSD = DLookup("[exrate]", "pub_ccyex", "[toccykey] = 'USD' ")
SQL = "Update tbCurrencyRatesTEST Set Rate = M4KUSD where [CUR] = 'USD' "
Msgbox(M4KUSD)
DoCmd.RunSQL SQL