Hello Forum,
I'm building a new "grades" program in Access 2007 for an English instructor at a local community college. The opening form has a combo box to select an existing course (I call it a "course" to avoid confusion with the programming term "class") or create a new course. If the user selects to create a new course, a new unbound form opens with three unbound text boxes to gather the needed data: the course code, the course description, and the start date. The code for the button to append a row to the tblCourses table is as follows:
Code:
Private Sub cmdCreateCourse_Click()
Dim rcc As Integer
Dim description As String
Dim start As Date
rcc = Me!txtRCC_ID
description = Me!txtCourseName
start = Me!txtStartDate
Dim StrSQL As String
StrSQL = "INSERT INTO tblCourses ( RCC_ID, CourseDescription, StartDate) "
StrSQL = StrSQL & "VALUES (" & rcc & ", " & description & ", " & start & ")"
' the message box below is for testing purposes and is commented out
' However, when it is enabled, the message box does properly display the
' query with the correct values in it.
' msgbox StrSQL
DoCmd.RunSQL StrSQL
End Sub
This creates a Run-time error '3075': Syntax error (missing operator) in query expression.
I cannot see anything wrong with my query. I tried it both with and without the trailing semicolon, but that made no difference.
Any ideas? Thanks.