Problem with Insert

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Something is wrong with my statement. It does not instert the item into the
table.
FRM:ADVERSE_EVENTS - is the main form
InterviewID - it should be interviewId, but it gets corrected to
InterviewID, is on the main form in a text box

project coordinator - is the table where i want to put the information
InterviewID - is the field in project coordinator where the value should be
input into

The error I'm getting is Syntax error on INSERT INTO statement


Dim str As Long
str = Forms![FRM:ADVERSE_EVENTS].InterviewID
strSQL = "INSERT INTO project coordinator (InterviewID) " & "VALUES (" & str
& ");"
CurrentDb.Execute strSQL
 
Hi,
Is InterviewID a number?
Please do a:
Debug.Print strSql

and post the evaluated string so we can see it.
 
Yes InterviewID is a number

I put the debug.print SQL in and it didn't print anthing I went through the
debugger and strSQL just has the whole statement in there not a number

Dan Artuso said:
Hi,
Is InterviewID a number?
Please do a:
Debug.Print strSql

and post the evaluated string so we can see it.

--
HTH
-------
Dan Artuso, MVP


pokdbz said:
Something is wrong with my statement. It does not instert the item into the
table.
FRM:ADVERSE_EVENTS - is the main form
InterviewID - it should be interviewId, but it gets corrected to
InterviewID, is on the main form in a text box

project coordinator - is the table where i want to put the information
InterviewID - is the field in project coordinator where the value should be
input into

The error I'm getting is Syntax error on INSERT INTO statement


Dim str As Long
str = Forms![FRM:ADVERSE_EVENTS].InterviewID
strSQL = "INSERT INTO project coordinator (InterviewID) " & "VALUES (" & str
& ");"
CurrentDb.Execute strSQL
 
Ok I had strSQL as a string not a long. I changed that and it got rid of the
syntax error but it is havning a 0 now in strSQL not the number in str.

Dan Artuso said:
Hi,
Is InterviewID a number?
Please do a:
Debug.Print strSql

and post the evaluated string so we can see it.

--
HTH
-------
Dan Artuso, MVP


pokdbz said:
Something is wrong with my statement. It does not instert the item into the
table.
FRM:ADVERSE_EVENTS - is the main form
InterviewID - it should be interviewId, but it gets corrected to
InterviewID, is on the main form in a text box

project coordinator - is the table where i want to put the information
InterviewID - is the field in project coordinator where the value should be
input into

The error I'm getting is Syntax error on INSERT INTO statement


Dim str As Long
str = Forms![FRM:ADVERSE_EVENTS].InterviewID
strSQL = "INSERT INTO project coordinator (InterviewID) " & "VALUES (" & str
& ");"
CurrentDb.Execute strSQL
 
Hi,
It prints it to the debug window (press ctl-G to see it), then post the string

--
HTH
-------
Dan Artuso, MVP


pokdbz said:
Yes InterviewID is a number

I put the debug.print SQL in and it didn't print anthing I went through the
debugger and strSQL just has the whole statement in there not a number

Dan Artuso said:
Hi,
Is InterviewID a number?
Please do a:
Debug.Print strSql

and post the evaluated string so we can see it.

--
HTH
-------
Dan Artuso, MVP


pokdbz said:
Something is wrong with my statement. It does not instert the item into the
table.
FRM:ADVERSE_EVENTS - is the main form
InterviewID - it should be interviewId, but it gets corrected to
InterviewID, is on the main form in a text box

project coordinator - is the table where i want to put the information
InterviewID - is the field in project coordinator where the value should be
input into

The error I'm getting is Syntax error on INSERT INTO statement


Dim str As Long
str = Forms![FRM:ADVERSE_EVENTS].InterviewID
strSQL = "INSERT INTO project coordinator (InterviewID) " & "VALUES (" & str
& ");"
CurrentDb.Execute strSQL
 
it prints 0 and says type mismatch

Dan Artuso said:
Hi,
It prints it to the debug window (press ctl-G to see it), then post the string

--
HTH
-------
Dan Artuso, MVP


pokdbz said:
Yes InterviewID is a number

I put the debug.print SQL in and it didn't print anthing I went through the
debugger and strSQL just has the whole statement in there not a number

Dan Artuso said:
Hi,
Is InterviewID a number?
Please do a:
Debug.Print strSql

and post the evaluated string so we can see it.

--
HTH
-------
Dan Artuso, MVP


Something is wrong with my statement. It does not instert the item into the
table.
FRM:ADVERSE_EVENTS - is the main form
InterviewID - it should be interviewId, but it gets corrected to
InterviewID, is on the main form in a text box

project coordinator - is the table where i want to put the information
InterviewID - is the field in project coordinator where the value should be
input into

The error I'm getting is Syntax error on INSERT INTO statement


Dim str As Long
str = Forms![FRM:ADVERSE_EVENTS].InterviewID
strSQL = "INSERT INTO project coordinator (InterviewID) " & "VALUES (" & str
& ");"
CurrentDb.Execute strSQL
 
Hi,
Okay, your sql statement has to be a string. Why would you think this would be a number?
It represents your query.

Change it back and post the evaluated string!

--
HTH
-------
Dan Artuso, MVP


pokdbz said:
Ok I had strSQL as a string not a long. I changed that and it got rid of the
syntax error but it is havning a 0 now in strSQL not the number in str.

Dan Artuso said:
Hi,
Is InterviewID a number?
Please do a:
Debug.Print strSql

and post the evaluated string so we can see it.

--
HTH
-------
Dan Artuso, MVP


pokdbz said:
Something is wrong with my statement. It does not instert the item into the
table.
FRM:ADVERSE_EVENTS - is the main form
InterviewID - it should be interviewId, but it gets corrected to
InterviewID, is on the main form in a text box

project coordinator - is the table where i want to put the information
InterviewID - is the field in project coordinator where the value should be
input into

The error I'm getting is Syntax error on INSERT INTO statement


Dim str As Long
str = Forms![FRM:ADVERSE_EVENTS].InterviewID
strSQL = "INSERT INTO project coordinator (InterviewID) " & "VALUES (" & str
& ");"
CurrentDb.Execute strSQL
 
INSERT INTO project coordinator (InterviewID) VALUES (9999);
Was in the debug screen when i put in 9999

It also came up with the error with the INSTERT INTO syntax problem. Im
guessing it has something to do with the project coordinator table and the
InterviewID field.

Dan Artuso said:
Hi,
Okay, your sql statement has to be a string. Why would you think this would be a number?
It represents your query.

Change it back and post the evaluated string!

--
HTH
-------
Dan Artuso, MVP


pokdbz said:
Ok I had strSQL as a string not a long. I changed that and it got rid of the
syntax error but it is havning a 0 now in strSQL not the number in str.

Dan Artuso said:
Hi,
Is InterviewID a number?
Please do a:
Debug.Print strSql

and post the evaluated string so we can see it.

--
HTH
-------
Dan Artuso, MVP


Something is wrong with my statement. It does not instert the item into the
table.
FRM:ADVERSE_EVENTS - is the main form
InterviewID - it should be interviewId, but it gets corrected to
InterviewID, is on the main form in a text box

project coordinator - is the table where i want to put the information
InterviewID - is the field in project coordinator where the value should be
input into

The error I'm getting is Syntax error on INSERT INTO statement


Dim str As Long
str = Forms![FRM:ADVERSE_EVENTS].InterviewID
strSQL = "INSERT INTO project coordinator (InterviewID) " & "VALUES (" & str
& ");"
CurrentDb.Execute strSQL
 
I should have seen this from the start, oh well.
It appears your table name has a space in it. Enclose it in brackets [project coordinator]

Spaces in object names are bad.

--
HTH
-------
Dan Artuso, MVP


pokdbz said:
INSERT INTO project coordinator (InterviewID) VALUES (9999);
Was in the debug screen when i put in 9999

It also came up with the error with the INSTERT INTO syntax problem. Im
guessing it has something to do with the project coordinator table and the
InterviewID field.

Dan Artuso said:
Hi,
Okay, your sql statement has to be a string. Why would you think this would be a number?
It represents your query.

Change it back and post the evaluated string!

--
HTH
-------
Dan Artuso, MVP


pokdbz said:
Ok I had strSQL as a string not a long. I changed that and it got rid of the
syntax error but it is havning a 0 now in strSQL not the number in str.

:

Hi,
Is InterviewID a number?
Please do a:
Debug.Print strSql

and post the evaluated string so we can see it.

--
HTH
-------
Dan Artuso, MVP


Something is wrong with my statement. It does not instert the item into the
table.
FRM:ADVERSE_EVENTS - is the main form
InterviewID - it should be interviewId, but it gets corrected to
InterviewID, is on the main form in a text box

project coordinator - is the table where i want to put the information
InterviewID - is the field in project coordinator where the value should be
input into

The error I'm getting is Syntax error on INSERT INTO statement


Dim str As Long
str = Forms![FRM:ADVERSE_EVENTS].InterviewID
strSQL = "INSERT INTO project coordinator (InterviewID) " & "VALUES (" & str
& ");"
CurrentDb.Execute strSQL
 
Perfect, thanks for the help

Dan Artuso said:
I should have seen this from the start, oh well.
It appears your table name has a space in it. Enclose it in brackets [project coordinator]

Spaces in object names are bad.

--
HTH
-------
Dan Artuso, MVP


pokdbz said:
INSERT INTO project coordinator (InterviewID) VALUES (9999);
Was in the debug screen when i put in 9999

It also came up with the error with the INSTERT INTO syntax problem. Im
guessing it has something to do with the project coordinator table and the
InterviewID field.

Dan Artuso said:
Hi,
Okay, your sql statement has to be a string. Why would you think this would be a number?
It represents your query.

Change it back and post the evaluated string!

--
HTH
-------
Dan Artuso, MVP


Ok I had strSQL as a string not a long. I changed that and it got rid of the
syntax error but it is havning a 0 now in strSQL not the number in str.

:

Hi,
Is InterviewID a number?
Please do a:
Debug.Print strSql

and post the evaluated string so we can see it.

--
HTH
-------
Dan Artuso, MVP


Something is wrong with my statement. It does not instert the item into the
table.
FRM:ADVERSE_EVENTS - is the main form
InterviewID - it should be interviewId, but it gets corrected to
InterviewID, is on the main form in a text box

project coordinator - is the table where i want to put the information
InterviewID - is the field in project coordinator where the value should be
input into

The error I'm getting is Syntax error on INSERT INTO statement


Dim str As Long
str = Forms![FRM:ADVERSE_EVENTS].InterviewID
strSQL = "INSERT INTO project coordinator (InterviewID) " & "VALUES (" & str
& ");"
CurrentDb.Execute strSQL
 
Back
Top