Results 1 to 7 of 7
  1. #1
    MowsMek is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Mar 2015
    Posts
    3

    Applying a filter to a report via a button

    Hi everyone,

    I am sorry in advance for my english, I am french, but I will do my best to be comprehensible and not to make too many mistakes.

    I created a report in Access 2013 made of 4 categories (SNGCU, date, rectification & 543#). I am trying to filter the report via multiple buttons that would open the report, show the 4 categories for a single serial number. For example the first button would be (caption:0075) and would open all the reports with 0075 as a serial number (SNGCU). The second button would be 0120 and do the same for the SNGCU 0120, etc. I tried using the following code on the click event...

    DoCmd.OpenReport "HistoryRecord", acViewReport, "[SNGCU]='" & Me.Caption & "'"

    But it opens the full report with all the serial numbers.

    I am really really new to access and have no background in programming what so ever so if you could help me it would be much appreciated.



    Thank you.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    For starters you have the wherecondition in the filter argument. Add a comma before it. Second, Me refers to the form, so Caption refers to the form's, not the buttons.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    MowsMek is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Mar 2015
    Posts
    3
    So how would I write it would include the caption from the button?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Me.ButtonName.Caption

    or just hard code it:

    "SNGCU = '0120'"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    MowsMek is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Mar 2015
    Posts
    3
    Quote Originally Posted by pbaldy View Post
    Me.ButtonName.Caption

    or just hard code it:

    "SNGCU = '0120'"
    It doesn't work, the report opens but it is not filtered.
    It still shows all the records:/

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Quote Originally Posted by MowsMek View Post
    It doesn't work, the report opens but it is not filtered.
    It still shows all the records:/
    What exactly is your code now?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Merging fields and applying hyperlink in report
    By funkmasterjo_d in forum Reports
    Replies: 3
    Last Post: 12-27-2013, 02:34 PM
  2. Replies: 4
    Last Post: 04-22-2013, 06:45 AM
  3. Apply Filter 2 criteria not applying
    By ahightower in forum Forms
    Replies: 4
    Last Post: 07-28-2011, 03:31 PM
  4. Access Reports - Applying a subform filter
    By AMCUser in forum Queries
    Replies: 13
    Last Post: 06-25-2010, 07:32 PM
  5. Applying a filter to a combo box
    By bugchaser in forum Programming
    Replies: 1
    Last Post: 02-20-2009, 02:37 PM

Tags for this Thread

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