Set a filter in a databound table


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Set a filter in a databound table

  1. #1
    Jim Donnelly Guest

    Set a filter in a databound table




    I have created a simple form containing a SSTab of two pages. This is bound
    to a FoxPro 6.0 table with the following properties set on the data control:

    Connect: FoxPro 3.0
    Default cursor type: 1 – ODBC Cursor
    Recordset type: 0 – Table
    Recordsource: ltrser

    The table in use contains records of two types of entries, memos and letters.
    The field “type” contains either “M” or “L”. What I want to do is set a filter
    to view one or the other type depending upon the page selected on the SSTab,
    (Memos on one page; letters on the other). In FoxPro this is accomplished
    with a one-line entry in the ‘click’ event, ‘Set filter to type = “M”’.
    What is the syntax for setting this filter in Visual Basic?

    Jim Donnelly


  2. #2
    Dennis Guest

    Re: Set a filter in a databound table


    The direct answer to your question is to use the Filter property of an ADO
    recordset.

    recordset.Filter = "type = 'M'"

    However, you may be better off with 2 recordsets, one with all "M" and one
    with all "L". That would eliminate the potential problems you would have
    with positioning on records in the recordset when you filter back and forth.

    Dennis


    "Jim Donnelly" <DonnellyJ@vab.alliedtech.com> wrote:
    >
    >
    >
    >I have created a simple form containing a SSTab of two pages. This is bound
    >to a FoxPro 6.0 table with the following properties set on the data control:
    >
    >Connect: FoxPro 3.0
    >Default cursor type: 1 – ODBC Cursor
    >Recordset type: 0 – Table
    >Recordsource: ltrser
    >
    >The table in use contains records of two types of entries, memos and letters.
    >The field “type” contains either “M” or “L”. What I want to do is set a

    filter
    >to view one or the other type depending upon the page selected on the SSTab,
    >(Memos on one page; letters on the other). In FoxPro this is accomplished
    >with a one-line entry in the ‘click’ event, ‘Set filter to type = “M”’.


    >What is the syntax for setting this filter in Visual Basic?
    >
    >Jim Donnelly
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center