Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Nov 2001
    Location
    Northwich, Cheshire UK
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    change record source for a report (Access 2000)

    Hello there,

    I am trying to change the record source for a report by picking up the table name from a combo box and assigning it to the record source property of the report. Unfortunately I am not having much joy doing this. Can somebody out there please explain to me how you can pick up a value chosen in a combo box and then assign this value to another property, text box etc.etc.

    Any help is much appreciated. <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29>

    Regards,

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: change record source for a report (Access 2000)

    I'm not sure it will work, but you might be able to set the report's recordsource in its Open event by referring to the combobox on the form, something like:

    Me.recordsource = Forms!yourFormName!cboTable
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Lounger
    Join Date
    Apr 2001
    Location
    Stuttgart, Germany
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: change record source for a report (Access 2000)

    Hi Mark, Harry,

    setting the recordsource in Report_Open does work. Moreover, this is the only place you can do it.

  4. #4
    2 Star Lounger
    Join Date
    Dec 2000
    Posts
    188
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: change record source for a report (Access 2000)

    Hello Mark, Harry, and Emilia!

    Report_Open is actually not the only place you can set the record source of a report.

    IF, I say IF this is something just for you and not for your end user(s) you can use a DoCmd.OpenReport to open the report in design view, set the RecordSource by using Reports("yourReportName").RecordSource="RecordSour ceString", then issue the DoCmd.OpenReport in Preview (or Normal if you don't care to check things out before sending to the printer).

    The form method works nicely if you set your options on your form, then issue the DoCmd.OpenReport, and as has been discussed, have the on open event look at the form for the desired record source. you could even have code in the on open that checks if the form supplying the record source is open, and if not, cancel the opening of the report, etc.

    Naturally you'll be asked to save the changes to the report when you close it, but you can simply choose no.

    FWIW and HTH

  5. #5
    New Lounger
    Join Date
    Nov 2001
    Location
    Northwich, Cheshire UK
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: change record source for a report (Access 2000)

    Hello there,

    I have tried Mark's method and this does the trick for me. Thank you all for replying and your sugestions.

    Many big thanks,

    Regards

Posting Permissions

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