Form vb syntax error on INSERT INTO

G

Guest

From a form procedure I'm trying to write the value into a table. I have
tried keeping it simple at first, i.e. just writing a static number to prove
it works prior to adding the field name, however I am getting a syntax error.

Set DB = CurrentDb
strSQL = "INSERT INTO Criteria (GetValueN)VALUES " & "2" & ";"
DoCmd.RunSQL (strSQL)

My table is [Criteria]
The field is [GetValueN] and it's numeric
The field name is [COMPETENCY_ID] and the Control Source is [Competency
Identifier]

Help please?
 
D

Douglas J. Steele

strSQL = "INSERT INTO Criteria (GetValueN) VALUES (" & "2" & ")"

or, to use the control,


strSQL = "INSERT INTO Criteria (GetValueN) VALUES (" & Me.Competency_ID &
")"
 
R

Rick Brandt

Paul said:
From a form procedure I'm trying to write the value into a table. I
have tried keeping it simple at first, i.e. just writing a static
number to prove it works prior to adding the field name, however I am
getting a syntax error.

Set DB = CurrentDb
strSQL = "INSERT INTO Criteria (GetValueN)VALUES " & "2" & ";"
DoCmd.RunSQL (strSQL)

My table is [Criteria]
The field is [GetValueN] and it's numeric
The field name is [COMPETENCY_ID] and the Control Source is
[Competency Identifier]

Help please?

The VALUES list should be surrounded by parenthesis...

Set DB = CurrentDb
strSQL = "INSERT INTO Criteria (GetValueN) VALUES(" & "2" & ");"
DoCmd.RunSQL (strSQL)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top