append (INSERT INTO) query problems

R

Richard Hollenbeck

I'm very sorry for reposting this, but I made a mistake on the first post
and I tried to fix it with a reply. Usually whenever I reply to my own
posts I never receive a reply from the group. Here's the corrected version
of my original post:

I have two functions: getCC and getCD. One will prompt the user for a
course code (getCC) for a new college course, and the other will prompt the
user for a course description (getCD) for the same new college course. I
want to append (INSERT INTO) the table [courses] with this new course.

Here are the two functions and the subroutine with the query:

Private Function getCC() As String
getCC = Nz(InputBox("Input course code for new course. . .", "New course
code"))
End Function

Private Function getCD() As String
getCD = Nz(InputBox("Input course description for new course. . .", "New
course description"))
End Function

Private Sub cmdNewCourse_Click()
Dim StrSQL As String
StrSQL = "INSERT INTO courses(courseCode, courseDescription) "
StrSQL = StrSQL & "VALUES ('" & getCC & "' , '" & getCD & "');"
CurrentDb.Execute StrSQL, dbFailOnError
End Sub

Apologies for the double posting and many thanks for any replies,

Rich Hollenbeck
 
T

tina

you didn't mention just what the problem is. how do you know it's a syntax
error - are you getting an error message, and if so what is it? or is the
Append query completing but not entering the value(s) you expected into the
table? etc, etc, etc.
 
R

Richard Hollenbeck

Run-time error '3134':
Syntax error in INSERT INTO statement.


tina said:
you didn't mention just what the problem is. how do you know it's a syntax
error - are you getting an error message, and if so what is it? or is the
Append query completing but not entering the value(s) you expected into the
table? etc, etc, etc.


Richard Hollenbeck said:
I'm very sorry for reposting this, but I made a mistake on the first post
and I tried to fix it with a reply. Usually whenever I reply to my own
posts I never receive a reply from the group. Here's the corrected version
of my original post:

I have two functions: getCC and getCD. One will prompt the user for a
course code (getCC) for a new college course, and the other will prompt the
user for a course description (getCD) for the same new college course. I
want to append (INSERT INTO) the table [courses] with this new course.

Here are the two functions and the subroutine with the query:

Private Function getCC() As String
getCC = Nz(InputBox("Input course code for new course. . .", "New course
code"))
End Function

Private Function getCD() As String
getCD = Nz(InputBox("Input course description for new course. . .", "New
course description"))
End Function

Private Sub cmdNewCourse_Click()
Dim StrSQL As String
StrSQL = "INSERT INTO courses(courseCode, courseDescription) "
StrSQL = StrSQL & "VALUES ('" & getCC & "' , '" & getCD & "');"
CurrentDb.Execute StrSQL, dbFailOnError
End Sub

Apologies for the double posting and many thanks for any replies,

Rich Hollenbeck
 
R

Richard Hollenbeck

I couldn't figure out what was wrong with my query so I shut the thing down
and took a nap. I just came back to work on it and tried the command button
with the query behind it to reproduce the error. To my surprise it worked!
I didn't change anything. No run-time error. It just read the values from
the input boxes and inserted them into the table like it was supposed to.
No problems. I can't figure out why a query gets "stuck on stupid" until I
reboot Access, but it did. When I rebooted my computer and went back to my
program everything worked perfectly.

Thanks anyway for the effort.

Richard Hollenbeck said:
Run-time error '3134':
Syntax error in INSERT INTO statement.


tina said:
you didn't mention just what the problem is. how do you know it's a syntax
error - are you getting an error message, and if so what is it? or is the
Append query completing but not entering the value(s) you expected into the
table? etc, etc, etc.


Richard Hollenbeck said:
I'm very sorry for reposting this, but I made a mistake on the first post
and I tried to fix it with a reply. Usually whenever I reply to my own
posts I never receive a reply from the group. Here's the corrected version
of my original post:

I have two functions: getCC and getCD. One will prompt the user for a
course code (getCC) for a new college course, and the other will
prompt
the
user for a course description (getCD) for the same new college course. I
want to append (INSERT INTO) the table [courses] with this new course.

Here are the two functions and the subroutine with the query:

Private Function getCC() As String
getCC = Nz(InputBox("Input course code for new course. . .", "New course
code"))
End Function

Private Function getCD() As String
getCD = Nz(InputBox("Input course description for new course. .
..",
"New
course description"))
End Function

Private Sub cmdNewCourse_Click()
Dim StrSQL As String
StrSQL = "INSERT INTO courses(courseCode, courseDescription) "
StrSQL = StrSQL & "VALUES ('" & getCC & "' , '" & getCD & "');"
CurrentDb.Execute StrSQL, dbFailOnError
End Sub

Apologies for the double posting and many thanks for any replies,

Rich Hollenbeck
 
G

Gary Walter

Hi Richard,

Maybe a typo, but I believe you are missing a space
between "courses" and "(".

StrSQL = "INSERT INTO courses (courseCode, courseDescription) "

plus...are courseCode and courseDescription in table
courses type Text?
 
T

tina

eeek, shades of Access95! <cringe>
glad it ended up working, though. that's why i had asked for more info - i
couldn't see anything wrong with the code you posted.


Richard Hollenbeck said:
I couldn't figure out what was wrong with my query so I shut the thing down
and took a nap. I just came back to work on it and tried the command button
with the query behind it to reproduce the error. To my surprise it worked!
I didn't change anything. No run-time error. It just read the values from
the input boxes and inserted them into the table like it was supposed to.
No problems. I can't figure out why a query gets "stuck on stupid" until I
reboot Access, but it did. When I rebooted my computer and went back to my
program everything worked perfectly.

Thanks anyway for the effort.

Richard Hollenbeck said:
Run-time error '3134':
Syntax error in INSERT INTO statement.


tina said:
you didn't mention just what the problem is. how do you know it's a syntax
error - are you getting an error message, and if so what is it? or is the
Append query completing but not entering the value(s) you expected
into
the
table? etc, etc, etc.


I'm very sorry for reposting this, but I made a mistake on the first post
and I tried to fix it with a reply. Usually whenever I reply to my own
posts I never receive a reply from the group. Here's the corrected
version
of my original post:

I have two functions: getCC and getCD. One will prompt the user for a
course code (getCC) for a new college course, and the other will prompt
the
user for a course description (getCD) for the same new college
course.
I
want to append (INSERT INTO) the table [courses] with this new course.

Here are the two functions and the subroutine with the query:

Private Function getCC() As String
getCC = Nz(InputBox("Input course code for new course. . .", "New
course
code"))
End Function

Private Function getCD() As String
getCD = Nz(InputBox("Input course description for new course. . .",
"New
course description"))
End Function

Private Sub cmdNewCourse_Click()
Dim StrSQL As String
StrSQL = "INSERT INTO courses(courseCode, courseDescription) "
StrSQL = StrSQL & "VALUES ('" & getCC & "' , '" & getCD & "');"
CurrentDb.Execute StrSQL, dbFailOnError
End Sub

Apologies for the double posting and many thanks for any replies,

Rich Hollenbeck
 
R

Richard Hollenbeck

Thanks, Tina.

For my education, what about my code reminded you of Access 95? Or were you
referring to Access sticking with an error until the program reboots? Did
prior versions of Access have that problem more than 2002? I am using 2002
(XP).

Rich Hollenbeck

tina said:
eeek, shades of Access95! <cringe>
glad it ended up working, though. that's why i had asked for more info - i
couldn't see anything wrong with the code you posted.


Richard Hollenbeck said:
I couldn't figure out what was wrong with my query so I shut the thing down
and took a nap. I just came back to work on it and tried the command button
with the query behind it to reproduce the error. To my surprise it worked!
I didn't change anything. No run-time error. It just read the values from
the input boxes and inserted them into the table like it was supposed to.
No problems. I can't figure out why a query gets "stuck on stupid"
until
I
reboot Access, but it did. When I rebooted my computer and went back to my
program everything worked perfectly.

Thanks anyway for the effort.

is
the my
own
for
a
course code (getCC) for a new college course, and the other will prompt
the
user for a course description (getCD) for the same new college course.
I
want to append (INSERT INTO) the table [courses] with this new
course.
Here are the two functions and the subroutine with the query:

(without all the "> > > > >" arrows)

Private Function getCC() As String
getCC = Nz(InputBox("Input course code for new course. . .", "New
course code"))
End Function

Private Function getCD() As String
getCD = Nz(InputBox("Input course description for new course. . .",
"New course description"))
End Function

Private Sub cmdNewCourse_Click()
Dim StrSQL As String
StrSQL = "INSERT INTO courses(courseCode, courseDescription) "
StrSQL = StrSQL & "VALUES ('" & getCC & "' , '" & getCD & "');"
CurrentDb.Execute StrSQL, dbFailOnError
End Sub
 
T

tina

no, not your code, the mysteriously disappearing error. i used to have that
problem a lot in A95. and as i was new to database development, and
self-teaching, i always thought it was me - something i was doing wrong.
then after giving up and going home at midnight, i'd come in and test it the
next morning and it would run fine. and conversely, something would work
fine once, or several times, then quit working and i'd have to find another
way to do it. used to drive me up a wall! <grinning now, but not then!>


Richard Hollenbeck said:
Thanks, Tina.

For my education, what about my code reminded you of Access 95? Or were you
referring to Access sticking with an error until the program reboots? Did
prior versions of Access have that problem more than 2002? I am using 2002
(XP).

Rich Hollenbeck

tina said:
eeek, shades of Access95! <cringe>
glad it ended up working, though. that's why i had asked for more info - i
couldn't see anything wrong with the code you posted.


Richard Hollenbeck said:
I couldn't figure out what was wrong with my query so I shut the thing down
and took a nap. I just came back to work on it and tried the command button
with the query behind it to reproduce the error. To my surprise it worked!
I didn't change anything. No run-time error. It just read the values from
the input boxes and inserted them into the table like it was supposed to.
No problems. I can't figure out why a query gets "stuck on stupid"
until
I
reboot Access, but it did. When I rebooted my computer and went back
to
my
program everything worked perfectly.

Thanks anyway for the effort.

Run-time error '3134':
Syntax error in INSERT INTO statement.


you didn't mention just what the problem is. how do you know it's a
syntax
error - are you getting an error message, and if so what is it? or is
the
Append query completing but not entering the value(s) you expected into
the
table? etc, etc, etc.


I'm very sorry for reposting this, but I made a mistake on the first
post
and I tried to fix it with a reply. Usually whenever I reply to my
own
posts I never receive a reply from the group. Here's the corrected
version
of my original post:

I have two functions: getCC and getCD. One will prompt the user
for
a
course code (getCC) for a new college course, and the other will
prompt
the
user for a course description (getCD) for the same new college course.
I
want to append (INSERT INTO) the table [courses] with this new course.
Here are the two functions and the subroutine with the query:

(without all the "> > > > >" arrows)

Private Function getCC() As String
getCC = Nz(InputBox("Input course code for new course. . .", "New
course code"))
End Function

Private Function getCD() As String
getCD = Nz(InputBox("Input course description for new course. . .",
"New course description"))
End Function

Private Sub cmdNewCourse_Click()
Dim StrSQL As String
StrSQL = "INSERT INTO courses(courseCode, courseDescription) "
StrSQL = StrSQL & "VALUES ('" & getCC & "' , '" & getCD & "');"
CurrentDb.Execute StrSQL, dbFailOnError
End Sub
 

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