Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Feb 2002
    Posts
    155
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Recordsource, recordset and filter (A2K SR1)

    When we want to get records that satisfy a certain criterion, we can formulate the SQL statement for it.
    I understand that we can achieve the above with one of the following strategies:
    (a) set the recordsource of the form that satisfies the SQL,
    ([img]/forums/images/smilies/cool.gif[/img] get the recordset of the table that satisfies the SQL criterion, or
    use a filter similar to the WHERE clause of the SQL statement.

    My question is - is there any differences amongst the three ways and what are their performance penalty?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Recordsource, recordset and filter (A2K SR1)

    ([img]/forums/images/smilies/cool.gif[/img] is different from (a) and : both (a) and will cause the form to display only the filtered records. ([img]/forums/images/smilies/cool.gif[/img] will only give you a recordset that can be manipulated in code - unless you set the RecordSource of the form, in which case it's the same as (a).

    In case (a) the records not satisfying the criteria are inaccessible until you change the RecordSource of the form again. In case the user can turn off the filter to see all records - unless you have set the CanFilter property of the form to No.

    I have the impression that changing the RecordSource is slightly more efficient - setting a filter seems to generate a lot of event handling. But in most cases, I don't think you'll notice the difference, and it probably depends on the design of your form (presence or absence of subforms, code in OnCurrent event etc.)

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

    Re: Recordsource, recordset and filter (A2K SR1)

    In my experience, it's faster to change the recordsource than to manipulate filters on large recordsets.
    Charlotte

  4. #4
    2 Star Lounger
    Join Date
    Feb 2002
    Posts
    155
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Recordsource, recordset and filter (A2K SR1)

    Thanks for your explanation, HansV. My tables contains only about 1000 rows and it is rather small. I experimnted with it and couldn't visibly find the difference. That's why I seek help. Thanks again, and to Charlotte too.

Posting Permissions

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