Docmd.runSQL Syntax

tuktuk

Well-known Member
Joined
Nov 13, 2006
Messages
856
Can anyone help me locate where the error is in the SQL Statement

Code:
strSql = "INSERT INTO tbl_Phone_Stats_by_Day (tsr, call_date, SumOftot_calls, SumOftime_connect, SumOftime_paused, SumOftime_waiting, SumOftime_deassigned, SumOflogon_time, logoff_time, SumOftime_acw ) " & vbCrLf & _
"SELECT " & "tsktsrhst" & strFullTableName & ".tsr," & "tsktsrhst" & strFullTableName & ".call_date,Sum(" & "tsktsrhst" & strFullTableName & ".tot_calls) AS SumOftot_calls, Sum(" & "tsktsrhst" & strFullTableName & ".time_connect) AS SumOftime_connect, Sum(" & "tsktsrhst" & strFullTableName & ".time_paused) AS SumOftime_paused, Sum(" & "tsktsrhst" & strFullTableName & ".time_waiting) AS SumOftime_waiting, Sum(" & "tsktsrhst" & strFullTableName & ".time_deassigned) AS SumOftime_deassigned, Sum(" & "tsktsrhst" & strFullTableName & ".logon_time) AS SumOflogon_time," & "tsktsrhst" & strFullTableName & ".logoff_time, Sum( " & "tsktsrhst" & strFullTableName & ".time_acw) AS SumOftime_acw" & vbCrLf & _
"FROM " & "tsktsrhst" & strFullTableName & vbCrLf & _
"GROUP BY " & "tsktsrhst" & strFullTableName & ".tsr""," & "tsktsrhst" & strFullTableName & ".call_date""," & "tsktsrhst" & strFullTableName & ".logoff_time;"


i'm usign a dynamic name for the table in the select where the table is = "tsktsrhst" & strFullTableName where strFullTableName represents a date....exaple would be "tsktsrhst123114" so my first select would be "tsktsrhst123114.tsr"
thanks
tuktuk
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
SOLUTION: so instead of having a dynamic table name in the string i decided to simply change the name of the table to "tsktsrhstDAILY" before i run the docmd.run sql. that way i do not have to alter the strSql statement.

thanks
tuk
 
Upvote 0

Forum statistics

Threads
1,215,523
Messages
6,125,322
Members
449,218
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top