R
Ron
Hello,
I have some code (commented out for now) that I am trying
to add on to the following:
Private Sub SaveButton_Click()
On Error GoTo Err_SaveButton_Click
' Add observe record
' Determine call id of most recently added observe record
' Add error records
' Reset unbound fields except observation date and reviewer
DoCmd.SetWarnings (False)
SQLStr1 = "INSERT INTO [Call Table] (CSAID,
ObservationDate"
SQLStr2 = [Forms]![Phone Observe Adds].[CSAID] & ", "
SQLStr3 = "#" & [Forms]![Phone Observe Adds].
[ObservationDate] & "#, "
If ("" = [Forms]![Phone Observe Adds].[ReviewerName])
Then
SQLStr4 = ""
Else
SQLStr1 = SQLStr1 & ", ReviewerName"
SQLStr4 = "'" & [Forms]![Phone Observe Adds].
[ReviewerName] & "', "
End If
If ("" = [Forms]![Phone Observe Adds].[VOCCode]) Then
SQLStr5 = ""
Else
SQLStr1 = SQLStr1 & ", VOCCode"
SQLStr5 = "'" & [Forms]![Phone Observe Adds].
[VOCCode] & "', "
End If
If ("" = [Forms]![Phone Observe Adds].[GroupNbr]) Then
SQLStr6 = ""
Else
SQLStr1 = SQLStr1 & ", GroupNbr"
SQLStr6 = "'" & [Forms]![Phone Observe Adds].
[GroupNbr] & "', "
End If
If ("" = [Forms]![Phone Observe Adds].[Product]) Then
SQLStr7 = ""
Else
SQLStr1 = SQLStr1 & ", Product"
SQLStr7 = "'" & [Forms]![Phone Observe Adds].
[Product] & "', "
End If
If ("" = [Forms]![Phone Observe Adds].[CallBack]) Then
SQLStr1 = SQLStr1 & ", CallBack) VALUES ("
SQLStr8 = "'No');"
Else
SQLStr1 = SQLStr1 & ", CallBack) VALUES ("
SQLStr8 = "'" & [Forms]![Phone Observe Adds].
[CallBack] & "');"
End If
'If ("" = [Forms]![Phone Observe Adds].[Comments]) Then
' SQLStr1 = SQLStr1 & ", Comments) VALUES ("
' SQLStr9 = "' ');"
'Else
' SQLStr1 = SQLStr1 & ", Comments) VALUES ("
' SQLStr9 = """" & [Forms]![Phone Observe Adds].
[Comments] & """);"
'End If
SQLStr10 = SQLStr1 & SQLStr2 & SQLStr3 & SQLStr4 &
SQLStr5 & SQLStr6 & SQLStr7 & SQLStr8 '& SQLStr9
DoCmd.RunSQL SQLStr10
Access gives me the error message, "Syntax Error in INSERT
INTO statement"... when trying to enter comments on the
form. Can someone help decipher what Access is not liking
with my code?
Thank you!
Ron
I have some code (commented out for now) that I am trying
to add on to the following:
Private Sub SaveButton_Click()
On Error GoTo Err_SaveButton_Click
' Add observe record
' Determine call id of most recently added observe record
' Add error records
' Reset unbound fields except observation date and reviewer
DoCmd.SetWarnings (False)
SQLStr1 = "INSERT INTO [Call Table] (CSAID,
ObservationDate"
SQLStr2 = [Forms]![Phone Observe Adds].[CSAID] & ", "
SQLStr3 = "#" & [Forms]![Phone Observe Adds].
[ObservationDate] & "#, "
If ("" = [Forms]![Phone Observe Adds].[ReviewerName])
Then
SQLStr4 = ""
Else
SQLStr1 = SQLStr1 & ", ReviewerName"
SQLStr4 = "'" & [Forms]![Phone Observe Adds].
[ReviewerName] & "', "
End If
If ("" = [Forms]![Phone Observe Adds].[VOCCode]) Then
SQLStr5 = ""
Else
SQLStr1 = SQLStr1 & ", VOCCode"
SQLStr5 = "'" & [Forms]![Phone Observe Adds].
[VOCCode] & "', "
End If
If ("" = [Forms]![Phone Observe Adds].[GroupNbr]) Then
SQLStr6 = ""
Else
SQLStr1 = SQLStr1 & ", GroupNbr"
SQLStr6 = "'" & [Forms]![Phone Observe Adds].
[GroupNbr] & "', "
End If
If ("" = [Forms]![Phone Observe Adds].[Product]) Then
SQLStr7 = ""
Else
SQLStr1 = SQLStr1 & ", Product"
SQLStr7 = "'" & [Forms]![Phone Observe Adds].
[Product] & "', "
End If
If ("" = [Forms]![Phone Observe Adds].[CallBack]) Then
SQLStr1 = SQLStr1 & ", CallBack) VALUES ("
SQLStr8 = "'No');"
Else
SQLStr1 = SQLStr1 & ", CallBack) VALUES ("
SQLStr8 = "'" & [Forms]![Phone Observe Adds].
[CallBack] & "');"
End If
'If ("" = [Forms]![Phone Observe Adds].[Comments]) Then
' SQLStr1 = SQLStr1 & ", Comments) VALUES ("
' SQLStr9 = "' ');"
'Else
' SQLStr1 = SQLStr1 & ", Comments) VALUES ("
' SQLStr9 = """" & [Forms]![Phone Observe Adds].
[Comments] & """);"
'End If
SQLStr10 = SQLStr1 & SQLStr2 & SQLStr3 & SQLStr4 &
SQLStr5 & SQLStr6 & SQLStr7 & SQLStr8 '& SQLStr9
DoCmd.RunSQL SQLStr10
Access gives me the error message, "Syntax Error in INSERT
INTO statement"... when trying to enter comments on the
form. Can someone help decipher what Access is not liking
with my code?
Thank you!
Ron