I'm having some problems with code I've written to insert data into a table.
I've used the following with no problems:
CurrentDb.Execute "INSERT INTO tblVialDepth(Depth) VALUES (2000)"
However, if I try to use a variable like this:
Dim sngTestValue As Single
sngTestValue = "2345"
CurrentDb.Execute "INSERT INTO tblVialDepth(Depth) VALUES sngTestValue"
I get the following run-time error 3134 - Syntax error in INSERT INTO statement.
The reason I need to use a variable is that I will be changing the value of the variable based on a query (hence the query forum) and run a series of IF THEN statement to put all the values I want into the table.
Any help with how to have a variable name like sngTestValue work in the SQL statement instead of having to use a fixed value like (2000) would be greatly appreciated.