Results 1 to 5 of 5
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    Clear up a misconception?

    It's always been my understanding with reports that IF one needs to set RecordSource and filters in code when a report OPENs that the "Me.RecordSource =" should be coded in the OnOpen event and the filter property for the report be set in the OnActivate event. I seem to be having some problems with a report where the filter doesn't apply itself when I run the report.



    Can someone straighten me out on the proper placement of the required code to assign the RecordSource =, Filter = and FilterOn?

    Code:
    Me.Filter = strRptFilter
    Me.FilterOn = True

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    To apply a filter automatically when a form is opened, specify in the OnOpen event property setting of the form either a macro that uses the ApplyFilter action or an event procedure that uses the ApplyFilter method of the DoCmd object.
    Maybe on some of the ones you have trouble with, you have Filter On set to No? Not sure what the implications of that would be. I presume code would overr-ride, provided that it's placed properly. I'd also say that Activate is too late - the report is already poplualted and formatted.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Thanks Micron. I think my problem stems from my misunderstanding of how and when OnActivate code takes effect. I'll put the pertinent code in the OnOpen in a bit and report back.
    Bill

  4. #4
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Thanks Micron. I think my problem stems from my misunderstanding of how and when OnActivate code takes effect. I'll put the pertinent code in the OnOpen in a bit and report back.
    Bill

    Two problems revealed as I continued in Debug mode. The first was that I had the Me.Filter = AND Me.FilterOn = True in the OnActivate event rather than OnOpen where it belonged. The second issue was a simple oversight on my part when setting the filter expression itself. Both corrected and the report now runs as desired.
    Thanks again,
    Bill

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Glad to help.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Clear form
    By wickedjc in forum Access
    Replies: 2
    Last Post: 02-02-2016, 06:18 PM
  2. Clear a table
    By aaslezak in forum Macros
    Replies: 4
    Last Post: 05-18-2015, 10:35 AM
  3. Clear Multivaluefield
    By greggue in forum Forms
    Replies: 1
    Last Post: 08-27-2013, 11:51 AM
  4. Clear combo box
    By Cindygo in forum Forms
    Replies: 3
    Last Post: 09-19-2011, 09:25 AM
  5. Clear some fields and not others
    By funkygoorilla in forum Access
    Replies: 12
    Last Post: 08-23-2011, 07:38 AM

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