Results 1 to 3 of 3

Thread: ReSOLVED : Report RecordSource property !

  1. #1

    Thread Starter
    Member Alankar's Avatar
    Join Date
    Jun 2005
    Location
    Ghaziabad, India
    Posts
    40

    Resolved 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
    Last edited by Alankar; Jun 24th, 2005 at 04:09 AM.
    The rest of mind is not in rest, It rests in rest.

  2. #2
    Hyperactive Member nagasrikanth's Avatar
    Join Date
    Nov 2004
    Location
    India,Hyderabad.
    Posts
    420

    Lightbulb 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 ...

    thanx & regards
    Anu..
    The Difference between a Successful person and others is not a Lack of Knowledge,
    But rather a Lack of WILL

  3. #3

    Thread Starter
    Member Alankar's Avatar
    Join Date
    Jun 2005
    Location
    Ghaziabad, India
    Posts
    40

    Resolved 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.
    The rest of mind is not in rest, It rests in rest.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width