How to output my VBA SQL query to a report

shabbaranks

Registered User.
Local time
Today, 14:56
Joined
Oct 17, 2011
Messages
300
Hi,

Ive had a complete blank... Im trying to output my VBA code to a report but I cant for the life of me think how to do it.

Here is my code:

Code:
Dim strEmployeeName As String
strEmployeeName = EnUsername
DoCmd.RunSQL "SELECT StrConv(Replace([sUser],""."","" ""),3) AS Employee, TimesheetTable.Activity, TimesheetTable.Hours, TimesheetTable.Description, TimesheetTable.[Task Date], TimesheetTable.ProjectRef " & vbCrLf & _
"FROM TimesheetTable " & vbCrLf & _
"WHERE (((StrConv(Replace([sUser],""."","" ""),3)) Like """ & strEmployeeName & """) AND ((TimesheetTable.[Task Date])>=#" & [Forms]![DateSelection_Frm]![txtWeekCommencing] & "# And (TimesheetTable.[Task Date]<= #" & [Forms]![DateSelection_Frm]![txtWeekEnding] & "#)) AND ((TimesheetTable.ProjectRef) Not Like ""CENG*""));"

And my report is called TimeReport.

Any ideas please? Thanks
 
are you wanting to use the returned values of the sql above in a report, if so just create a report without a record source, add all the required text boxes and set the report record source to your sql in the report open event

BTW I don't think it's necessary to use vbcrlf in the sql, just ensure there are spaces between 'Select' items and 'From' items and any 'Where' clauses

David
 

Users who are viewing this thread

Back
Top Bottom