shabbaranks
Registered User.
- Local time
- Today, 15:01
- Joined
- Oct 17, 2011
- Messages
- 300
Hi guys, yep me again...
How do you show dates within SQL VBA? As Ive been struggling with the below code and cant for the life of me get it to work. Im sure its the date that's incorrect and Ive tried putting #'s in but still it errors with type mismatch. Could someone enlighten me please?
Thanks
How do you show dates within SQL VBA? As Ive been struggling with the below code and cant for the life of me get it to work. Im sure its the date that's incorrect and Ive tried putting #'s in but still it errors with type mismatch. Could someone enlighten me please?
Code:
strSQL = "SELECT TimesheetTable.ProjectRef, TimesheetTable.sUser, Sum(TimesheetTable.Hours) AS SumofHours, Month([task date]) AS [Month], Year([task date]) AS [Year]" & _
"FROM (UserNames_tbl INNER JOIN UserGroups_tbl ON UserNames_tbl.GroupID = UserGroups_tbl.GroupID) INNER JOIN (TimesheetTable INNER JOIN ProjectsTable ON TimesheetTable.ProjectRef = ProjectsTable.REFERENCE) ON UserNames_tbl.sUser = TimesheetTable.sUser" & _
"GROUP BY TimesheetTable.ProjectRef, TimesheetTable.sUser, Month([task date]), Year([task date]), Format([Task Date],'yyyymm', ProjectsTable.NAME2, UserNames_tbl.GroupID, UserNames_tbl.GroupID" & _
"HAVING (((TimesheetTable.ProjectRef) Not Like '" & CENG & "*') AND ((Month([task date]))=[Forms]![ChargeableHours]![MonthCombo]) AND ((Year([task date]))=[Forms]![ChargeableHours]![YearCombo]) AND ((UserNames_tbl.GroupID)<>7 And (UserNames_tbl.GroupID)<>8))" & _
"ORDER BY TimesheetTable.ProjectRef, TimesheetTable.sUser, Format([Task Date],'yyyymm');"
Me.RC_ListBox.RowSourceType = "Table/Query"
Me.RC_ListBox.ColumnCount = "5"
Me.RC_ListBox.ColumnWidth = "4cm;4cm;4cm;4cm;4cm"
Me.RC_ListBox.RowSource = strSQL
Thanks