Results 1 to 6 of 6
  1. #1
    bfg is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2020
    Posts
    9

    Multiple filter options for a report

    I have a report listing student achievements but I would like to include a filter with multiple options, eg filter the report by 'Free school meals students' OR 'Special Educational Need students' etc. Is there a way of allowing the user to choose the type of filter the user wants before the report runs and lists the resulting data.

    I don't particularly want to create a separate query for every possible option of filter choice as that could result in dozens of near identical reports being saved.

    Hope this makes some sense.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,538
    If you use VBA code to open the report you can set criteria to restrict the records shown. See Docmd.OpenReport: https://docs.microsoft.com/en-us/off...cmd.openreport
    You will need to give the user something that can be used to select the criteria and then build the argument used by Docmd.OpenReport
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    bfg is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2020
    Posts
    9
    Thanks for the rapid response Bob. I will try this out later today. I've never really got in to using VBA but the link you provide looks fairly straightforward...famous last words

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,538
    Quote Originally Posted by bfg View Post
    Thanks for the rapid response Bob. I will try this out later today. I've never really got in to using VBA but the link you provide looks fairly straightforward...famous last words
    Ha! Ha! Post back if you need more help
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

  6. #6
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    Code:
    sub btnFind_click()
    dim sWhere as string
    
    sWhere = "1=1"
    if not IsNull(txtBox1) then sWhere = sWhere & " and [field1]='" & me.txtBox1 & "'"
    if not IsNull(txtBox2) then sWhere = sWhere & " and [field2]='" & me.txtBox2 & "'"
    if not IsNull(cboBox) then sWhere = sWhere & " and [field3]='" & me.cboBox & "'"
    
    If sWhere = "1=1" Then
      docmd.OPenReport "rMyReport",acViewPreview
    Else
      docmd.OPenReport "rMyReport",acViewPreview,,sWhere
    End If
    end sub

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

Similar Threads

  1. Replies: 7
    Last Post: 06-13-2018, 12:45 PM
  2. Report filter form using multiple comboboxes.
    By Stephenson in forum Programming
    Replies: 9
    Last Post: 10-24-2015, 10:00 AM
  3. Filter Query combobox options
    By dhannant in forum Access
    Replies: 2
    Last Post: 05-12-2015, 03:25 AM
  4. Filter combobox options
    By Voodeux2014 in forum Forms
    Replies: 1
    Last Post: 03-17-2015, 10:57 AM
  5. Export to Excel with Filter Options
    By dcoley in forum Import/Export Data
    Replies: 1
    Last Post: 02-05-2014, 12:44 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