Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,424
    Provided Answers: 8

    Answered: Sub Report OnLoad Event

    What am i missing

    I have this code in a onload event in a report

    Code:
    Dim rst As Recordset
    Dim DB As Database
    Set DB = CurrentDb
    FD = -1
    Set rst = DB.OpenRecordset("LabelName")
    Do Until rst.EOF
        FD = FD + 1
        FDNAME = rst("Fyear")
        FF = rst("FF")
        Me("S" & FD).ControlSource = "=[" & FDNAME & "]"
        Me("F" & FD).Caption = FF
        rst.MoveNext
    Loop
    WORKS GREAT

    but when i put said report as subreport in a report that onload does not fire

    where have gone wrong
    Last edited by myle; 09-06-16 at 21:26. Reason: spelling
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  2. Best Answer
    Posted by myle

    "Fix I Put the code in the Report_open()

    Know it works "


  3. #2
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    495
    Provided Answers: 24
    You don't run thru record sets in a report via code.
    Connect the report to a query. It will cycle thru the records on its own.

    There's no need for code. Don't over complicate it.

  4. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    as its setting what looks like a caption then mebbe put it in a group header?
    ..granted its not the most efficient way of doing this, but its a report
    ..no point in putting it in a page hear as Im pretty certain page events are ignored in sub reports

    I know years ago some Access versions could 'forget' about vba code in events. cant rememeber if it was symptom of code compilation failures, corruption or just plain 'forgetfullness'. check the forms properties recognise there is code in the on load event. I think it used to occur most often when you entered event code in the VBA window directly, a naughty dirty thing to do, when there is a GUI that does the job for you....

    its possible that the on load event doesn't fire, or fires in a different manner when its a sub report

    failing that I'd place some debug statements to print to the immediate window to find out what events are firing and in what order
    I'd rather be riding on the Tiger 800 or the Norton

  5. #4
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,424
    Provided Answers: 8
    Fix I Put the code in the Report_open()

    Know it works
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

Posting Permissions

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