Results 1 to 6 of 6

Thread: ApplyFilter

  1. #1
    pthorn
    Guest

    ApplyFilter

    I am using Access 97.
    I have a form which is based upon a query that includes all fields I require from a particular table (Table 'A').

    In the header of the form I have a date field which I use as criteria for the ApplyFilter command.

    In the AfterUpdate event of the date field in the header I firstly delete all the records from Table 'A' with the same date as the date entered. I then populate Table 'A' from another table (Table 'B') based upon the date entered.
    I then use the Applyfilter command and nothing shows in the Detail section of the form, however if I goto the query and run the query I get all the records from Table 'A' that have been added from Table 'B'.
    I hope this is clear!!?
    Can somebody please help.
    [img]/w3timages/icons/sad.gif[/img]
    Pat

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: ApplyFilter

    Hi Pat,
    I think you may need to requery your form once you've added the records from table B to table A and before you try filtering.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    pthorn
    Guest

    Re: ApplyFilter

    Hi Rory,
    Thanks for your reply. I tried what you suggested, I put a forms!TrailRides.requery just before the docmd.applyfilter "qryTrailRides" and it still shows nothing in the detail section (these 2 commands are in the AfterUpdate of the date control in the header section). If I then go and run the query (by choosing the query tab, then opening the query) I get the correct records displayed.
    Any more ideas will be greatly appreciated.
    [img]/w3timages/icons/frown.gif[/img]
    Pat

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: ApplyFilter

    Is this code in the TrailRides form? Is qryTrailRides the record source for your form? If so, why are you trying to apply it as a filter? Instead try this:

    Me.Filter = "[RideDate]=" & [txtDate]
    Me.FilterOn = True

    where RideDate is assumed to be the name of the date field in your underlying datasource and [txtDate] is the name of the control in your form header.
    Charlotte

  5. #5
    pthorn
    Guest

    Re: ApplyFilter

    The code is in the AfterUpdate event of the date in the forms header. The query qryTrailRides is the record source of the form. I have tried what you said and put a me.query after those 2 lines of code, BUT it still does not work. However if I dont delete from the table then add records to the table it works beautifully. Is it the fact that I am deleting records from the table based upon the date and then adding records again based upon the same date then doing the requery.
    I am at a loss!!
    [img]/w3timages/icons/sad.gif[/img]
    Pat

  6. #6
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: ApplyFilter

    Hi Pat,
    Can you post the entire code in the AfterUpdate event?
    Regards,
    Rory

    Microsoft MVP - Excel

Posting Permissions

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