Trouble Inserting Records

mapat

Registered User.
Local time
Yesterday, 21:26
Joined
Feb 2, 2007
Messages
176
Hello,

I have the following stmt in VBA:

DoCmd.RunSQL "INSERT INTO tStudentYear(studentID,Year,schoolID) VALUES('" & theStudentID & "','2009','" & theSchoolID & "')"

being: theStudentID and theSchoolID both Strings.

It doesn't insert the records in the "tStudentYear" table, and I already added some MsgBoxes to see if theStudentID and theSchoolID were picking up the right info and they are.
Please note that it is not giving me a syntax error, it just does not insert the records into the table.

Thank you very much
 
What is the datatype of your year field? Based on your append query it appears to be a string as well, but if it is a fixed value then you don't need the single quotes around it. The word year is a reserved word in Access, so you might want to change your field name to something else. As an alternative, you might try putting square brackets around year as shown below. You also need a space between tStudentYear and (. With those changes the append query would look like this:


DoCmd.RunSQL "INSERT INTO tStudentYear (studentID,[Year],schoolID) VALUES('" & theStudentID & "',2009,'" & theSchoolID & "')"
 

Users who are viewing this thread

Back
Top Bottom