VBA SQL doesn't recognise variable value
Posted on 2003-11-01
I'm just learning VBA so I'm sure there is a simple answer to this. I've got a form with abutton that fires a VBA procedure;
Option Compare Database
Private Sub yy_Click()
Dim strSQL As String
Static name As String
name = "ali"
strSQL = "INSERT INTO staff2 (NAME, PHONE) VALUES ( " & name & ", 02067737783)"
When the button is clicked Access always pops a "Enter parameter value" box with the word 'ali' above an input field. If I type a value into the input box the query is successfuly completed.
However, I really want the query to insert the value of the variable 'name', and not to ask me to input a value. What am I doing wrong?