I don't know about ado, but your SQL seems off.
"INSERT INTO tblClassInfo(dblPassClassID,
strPassClassNo, strPassClassTitle, strJudge, strShowSection, strSectionID,
strClassTypeID, strClassStatus, strClassRef, intOpenID, strStatusID,
strSponsoredBy, strNameof)) VALUES (" & dblPassClassID & "," & strPassClassNo
& "," & strPassClassTitle & "," & strJudge & "," & strShowSection & "," &
strSectionID & "," & strClassTypeID & "," & strClassStatusID & "," &
strClassRef & "," & intOpenID & "," & strStatus & "," & strSponsoredBy & ","
& strNameOf & ")"
1. String values need to be surrounded by ''
2. your section "(dblPassClassID,
strPassClassNo, strPassClassTitle, strJudge, strShowSection, strSectionID,
strClassTypeID, strClassStatus, strClassRef, intOpenID, strStatusID,
strSponsoredBy, strNameof))" has too many closing brackets
The best thing is to add a break at the '.CommandType = adCmdText' line, run
your code and debug your SQL string. Try it in the Query Editor until you
get it right. Once you know your SQL is good, then you can continue working
on your code. But I think the issue is your SQL.
Also, when making a post. It is very helpful it your give us the exact
error number and even the error exact description that is raise.
Cleanup your SQL and try again.
--
Hope this helps,
Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples:
http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
"Simon" wrote:
> Hi
>
> I'm basically try to reused code from "Programming MS Access version2002"
>
> I get an EM telling there is a syntax error when sub below is called it
> debigs to the .execute line, the Variables are correctly containing the data
> I'm expecting - Can anyone help me understand where I've gone wrong?
>
> Many thanks
>
> Snippet of code:
>
> Sub UpdateSplit(strClassType As String, dblPassClassID As Double,
> strPassClassNo As String, strPassClassTitle As String, strJudge As String,
> strShowSection As String, strSectionID As String, strClassTypeID As String,
> strClassStatusID As String, strClassRef As String, intOpenID As Integer,
> strStatus As String, strSponsoredBy As String, strNameOf As String)
> Dim cmdUpdate As ADODB.Command
> Set cmdUpdate = New Command
> Select Case strClassType
> Case "Open"
> With cmdUpdate
> .ActiveConnection = CurrentProject.Connection
> .CommandText = "INSERT INTO tblClassInfo(dblPassClassID,
> strPassClassNo, strPassClassTitle, strJudge, strShowSection, strSectionID,
> strClassTypeID, strClassStatus, strClassRef, intOpenID, strStatusID,
> strSponsoredBy, strNameof)) VALUES (" & dblPassClassID & "," & strPassClassNo
> & "," & strPassClassTitle & "," & strJudge & "," & strShowSection & "," &
> strSectionID & "," & strClassTypeID & "," & strClassStatusID & "," &
> strClassRef & "," & intOpenID & "," & strStatus & "," & strSponsoredBy & ","
> & strNameOf & ")"
> .CommandType = adCmdText
> .Execute
> End With
>