insert VBA not working - GAH!!! (1 Viewer)

madEG

Registered User.
Local time
Today, 03:17
Joined
Jan 26, 2007
Messages
309
Hello,

Ok, I imagine I am overlooking something... why on Earth doesn't this work?

It's Access 2016/ODBC/SQL Server, *should be* simple insert, but I get syntax error...

Code:
strSQL = "Insert into dbo_OccurrenceMetrics (ActivityOccurrenceIDf, ActualCosts, ActualStaffHours, ActualStartDatetime, ActualEndDatetime, YesNo, TF, CompleteIncomplete, PercentageComplete, ValueRange, SubjectiveDesc1) VALUES (" & _
        
[listboxActivityOccurrences].[Value] & _
        ", '" & _
        numActualCosts & _
        "', '" & _
        numActualStaffHours & _
        "', " & _
        Chr(35) & dtmStartActual & Chr(35) & ", " & Chr(35) & dtmEndActual & Chr(35) & _
        ", '" & _
        cboYN & _
        "', '" & _
        cboTF & _
        "', '" & _
        cboCompleteIncomplete & _
        "', '" & _
        Replace(Format(Trim(txtPercentage)), "'", "''") & _
        "', '" & _
        Replace(Format(Trim(txtNumericRange)), "'", "''") & _
        "', '" & _
        Replace(Format(Trim(cboSubjectiveRange1)), "'", "''") & "');"
                             
        MsgBox ("strSQL: " & strSQL)

        'DoCmd.SetWarnings False
        DoCmd.RunSQL strSQL
        'DoCmd.SetWarnings True

The msgbox I included here, as well a screen shot of the table on the backend...

What am I not seeing? I'm going to blow a gasket!:banghead::banghead::banghead:

Thanks for any push in the right direction!

-Matt G.
 

Attachments

  • table_def.JPG
    table_def.JPG
    39.6 KB · Views: 63
  • string_msgbox.JPG
    string_msgbox.JPG
    29.5 KB · Views: 69

plog

Banishment Pending
Local time
Today, 02:17
Joined
May 11, 2011
Messages
11,646
Paste your SQL string into a new query object. Run it and see what error it gives if any.
 

Users who are viewing this thread

Top Bottom