Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Posts
    75

    Unanswered: Quickie--Multiselect List to Report

    I want to send the selected items from a multiselect list box to a report.... the code below will do this... but only after I close & reopen the report. How can I set [reports]![explanrpt]![plyolisttxt] to vplyo so that it will show immediately in Print Preview?? I'm sure this is simple, but I'm having a brain block. Any help?? Please?

    Private Sub ExPlanPrintCmd_Click()
    Dim frm As Form, ctl As Control, vPlyo As String
    Dim varItm As Variant
    Set frm = [Forms]![explanfrm]
    Set ctl = [Forms]![explanfrm]![PlyoList]
    For Each varItm In ctl.ItemsSelected
    vPlyo = vPlyo & ctl.ItemData(varItm) & Chr(13) & Chr(10)
    Next varItm
    DoCmd.OpenReport "ExPlanRpt", acViewPreview
    [Reports]![explanrpt]!plyolisttxt = vPlyo
    End Sub

    TIA

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Move the whole shebang to the on_open event of the report.

    When you call DoCmd.OpenReport, anything after that statement is going to wait until the report is generated. Therefore it's impossible to assign dynamic values to the report in the onclick event of your form. However,by moving the code to the on_open event of the report and only calling DoCmd.OpenReport from your form, you will dynamically load your values every time the report is opened.

    The only problem with this method is if you are NOT opening the report from the same form everytime. You'll get an error about "can't find such and such form" in such a case.
    Last edited by Teddy; 03-23-04 at 11:22.

  3. #3
    Join Date
    Jan 2004
    Posts
    75
    Thanks!!

    On_Open didn't work...

    But putting it in the On_Print event of the detail section did....


    Thanks a million! I would have spent the rest of the day ticked off if I couldn't figure that out...

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Originally posted by sublimsos
    Thanks!!

    On_Open didn't work...

    But putting it in the On_Print event of the detail section did....


    Thanks a million! I would have spent the rest of the day ticked off if I couldn't figure that out...
    Good to hear!

    I use on_open to set dynamic datasources for a report all the time. I suppose it makes more sense that on_print works for setting a text box inside the report.

    Learned something new!


Posting Permissions

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