Hello all,
I'm trying to take various values from text boxes and combo boxes on my form and insert them into a database, but I keep getting a syntax error.
The specific message is "Syntax error in INSERT INTO Statement."
I'm up to my eyes in quote marks here and I cannot figure out what's wrong.
Here's the code
I dunno what I'm doing wrong... sigh.Code:Private Sub CmdRC_Click() Dim SqlStr As String Dim cno As Integer Dim lco As Long If cmbCall.Value <> "" Then cno = cmbCall.Value Else MsgBox "You did not select a call number, selecting most recent.", vbOKOnly, "Error!" Me.cmbCall.SetFocus lco = cmbCall.ListCount - 1 Me.cmbCall = cmbCall.ItemData(lco) cno = cmbCall.Value End If If CmbCallRes.Value <> "" Then Else MsgBox "Error! No Result Selected!", vbCritical Exit Sub End If If txtEName.Value = "" Then MsgBox "Error! No Student Selected!", vbCritical Exit Sub End If SqlStr = " INSERT INTO [CallRecords] (CallNo, Student_EName, Student_KName, Student_Class, CDate, Time, Result) VALUES (" & cno & "," & "" & txtEName.Value & "" & "," & "" & txtKName.Value & "" & "," & "" & txtClass.Value & "" & "," & "" & txtCDate.Value & "" & "," & "" & txtCTime.Value & "" & "," & "" & CmbCallRes.Value & "" & ");" 'MsgBox SqlStr DoCmd.RunSQL (SqlStr) End Sub




Reply With Quote
