I have an SQL statement like this
strSQL = "SELECT MyField FROM MyTable WHERE PID = 301"
I wish to provide the Value for PID in the above statement through a variable and I wish to know the correct way of doing it if at all it is possible:
I have tried doing it like this:
Dim MyVariable as String
MyVariable as “Peter Smith”
strSQL = "SELECT MyField FROM MyTable WHERE PID = MyVariable"
How ever when I use the above approach I get an error message in my Code. I wish to know what would be the correct method for inserting a Variable in an SQL statement like the above.
Thank you for your help.