Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2003
    Posts
    41

    Unanswered: RunSQL - Syntax Error

    Good day,

    I am have a little trouble with RunSql command. I am getting a Syntax error and can'tfigure out why. I look @ the values in the debugger and it looks normal. The code I am using is:

    Private Sub cmdsubmit_Click()

    DoCmd.RunSQL "INSERT INTO tblmain (Trainer, Date, Week, A1_1, Comments1, A2_1, Comments2, A3_1, Comments3) Values (" & Forms!frmmain2!cbotrainer & ", #" & Forms!frmmain2!Date & "#," & Forms!frmmain2!cboweek & ", " & Forms!frmmain2!cboans1 & ", " & Forms!frmmain2!Comments1 & ", " & Forms!frmmain2!cboans2 & ", " & Forms!frmmain2!Comments2 & ", " & Forms!frmmain2!cboans3 & ", " & Forms!frmmain2!Comments3 & ")"

    End Sub

    Just wondering if anyone can see a problem.
    I also have attached the database.

    Thanks

  2. #2
    Join Date
    Jun 2004
    Location
    Florida, US
    Posts
    521
    This one worked for me:

    Dim SqlStr As String
    SqlStr = "INSERT INTO tblmain (Trainer, [Date], Week, A1_1, Comments1, A2_1, Comments2, A3_1, Comments3) Values ('" & Forms!frmmain2!cbotrainer & "', '" & Forms!frmmain2!Date & "'," & Forms!frmmain2!cboweek & ", '" & Forms!frmmain2!cboans1 & "', '" & Forms!frmmain2!Comments1 & "', '" & Forms!frmmain2!cboans2 & "', '" & Forms!frmmain2!Comments2 & "', '" & Forms!frmmain2!cboans3 & "', '" & Forms!frmmain2!Comments3 & "');"
    DoCmd.RunSQL (SqlStr)
    ghozy.

  3. #3
    Join Date
    Jul 2003
    Posts
    41
    Thanks for the help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •