ReSOLVED : Report RecordSource property !
Hi All,
I am trying to set Recordsource property of a report with VBA code. Is it necessary to open the report in design view first and then only I can set Recordsource property, As I am doing here ?
When I set the Recordsource property of Report without openning it in Design view I get an error message saying report is not open etc.
My VBA code is as follows :
---------------Code--------------------
str1 = "SELECT tbTimeSheet.DateRec, tbTimeSheet.PrjID, tbActivity.ActName, tbTimeSheet.ActCode, tbTimeSheet.Duration, tbTimeSheet.Remark, tbTimeSheet.EmpID" _
& " FROM tbActivity INNER JOIN tbTimeSheet ON tbActivity.ActCode = tbTimeSheet.ActCode" _
& " WHERE (((tbTimeSheet.EmpID)='" & EmpIDFT & "') AND ((Format([tbTimeSheet]![DateRec],'ww',2,3))>=" & cmbFrom.Value & " And (Format([tbTimeSheet]![DateRec],'ww',2,3))<=" & cmbTo.Value & "))"
DoCmd.Close acForm, "TmpInfo"
DoCmd.OpenReport "REmpRep", acViewDesign Reports!RempRep.RecordSource = str1
Reports!RempRep.Label20.Caption = "Report for " & EmpNameFT & "(Employee Code : " & EmpIDFT & ")"
DoCmd.Close acReport, "REmpRep", acSaveYes
DoCmd.OpenReport "REmpRep", acViewPreview
----------------------Code----------------------------
Can I change the Recordsource property without opening the report ? How ?
Please help.
Regards,
Alankar
Re: Report RecordSource property !
hi alankar
You can't set the record sets for a report with out opening it..
but the way to achive this is..transfer all u r code to
"REPORT OPEN" method...it will works..
but..it might necessary to use some of u r variables as global variables..
try it ... :thumb:
thanx & regards
Anu..
Resolved: Report RecordSource property !
OK, finally I have done.
I transferred the recordsource property on Report OnLoad event with using some global variable.
Thanks for help.