Results 1 to 4 of 4
  1. #1
    Bertrand82 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2012
    Posts
    48

    Filter from drop down in output report

    Hello Guys,



    I have a very simple vba code according to below where I export a pdf report.

    Q: I have a field in that report called "Company". I would like to filter that report with a drop down text box named "Companyfilter" where I choose a Company to only include values from that Company in the report.

    How do I change the code below?

    Thanks in advance!


    Private Sub RunReport_Click()

    DoCmd.OutputTo acOutputReport, "rptNameOfReport", "PDFFormat(*.pdf)", "H:\xxxxx\reports\nameofreport.pdf", False, "", , acExportQualityPrint


    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    This would not take place here....the QUERY that is in rptNameOfReport would handle it.
    On your form you would have the combo box for company...cboCo

    the query would have criteria that sees the combo... where [co] = forms!frmRpts!cboCo

    your RunRpt click would not change.

  3. #3
    Bertrand82 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2012
    Posts
    48
    yes I have the drop down list box on a form.

    I suppose I shall include a sql string in my vba code?

  4. #4
    IslandHydro is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2013
    Location
    Whidbey Island, Washington State, USA
    Posts
    21
    You can use the AfterUpdate event on the combobox to open the report with a filter like so:

    cboCo_AfterUpdate()
    Docmd.OpenReport("ReportName", acViewPreview,,"[co] ='" & cboCo & "'")
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 04-23-2014, 04:35 PM
  2. Replies: 6
    Last Post: 11-15-2012, 02:38 PM
  3. Table drop down list filter
    By jbataille86 in forum Access
    Replies: 2
    Last Post: 08-05-2011, 08:37 AM
  4. Filter available values in a drop down list
    By petitmorsalin in forum Access
    Replies: 1
    Last Post: 12-13-2010, 09:39 AM
  5. Replies: 19
    Last Post: 05-12-2009, 02:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums