Results 1 to 5 of 5

Thread: Filter by table *resolved*

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    Grand Rapids, MI
    Posts
    166

    Filter by table *resolved*

    I have 2 tables, tblIssues and tblTypes

    I want to filter the recordset a couple times by each record in tblTypes. For example,

    tblIssues has 4 columns,

    ID, p_id, summary and type_id

    tblTypes has 2 columns

    type_id, type

    tblTypes looks something like

    1 Dates
    2 Modifications
    3 Request
    4 Telemarketing

    each issue would be one of these types. I want to display all the issues in 4 separate tables, one for each type.
    Currently my recordset contains all the records. I know i can filter using the rs.Filter, but how can i loop it so that it filters and displays by each type in tblTypes?
    i know this sounds kind of confusing but I don't know how to explain it better.
    thanks.
    Last edited by Feetstink; Sep 10th, 2002 at 04:01 AM.

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Filter by table

    Originally posted by Feetstink
    I have 2 tables, tblIssues and tblTypes

    I want to filter the recordset a couple times by each record in tblTypes. For example,

    tblIssues has 4 columns
    ID, p_id, summary, type_id

    tblTypes has 2 columns
    type_id, type
    VB Code:
    1. strSql="Select tblIssues.*, tblTypes.[Type] from tblIssues Left Join tblTypes On tblIssues.Type_id=tblTypes.Type_id"
    2. 'strSql=strSql & " Where tblIssues.Type_id = " & cboTypes
    3. strsql=strSql & " Order By tblIssues.Type_id;"

    That will order them, you can loop through if you wish...

    I wouldn't separate them though, since in theory you could add more types and you'd then need to code and create a list box for each.

    Another way would be to filter the list by type using a combo box above the list box (just put the remarked line back in). This gives the users the ability to see all or just one type.


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    Grand Rapids, MI
    Posts
    166

    Re: Re: Filter by table

    I'm sorry, i'm still kind of new to this part of everything. I'm using this on an asp page, so I don't have a combo box or listbox or anything.
    I was hoping i could do something like

    for each typeName in tblTypes
    rs.Filter = "type = "& typeName
    ' code to print all the records in a table
    loop

    that way, no matter how many types i have in tblTypes, it will print that many tables.
    is this a little more clear?

  4. #4
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    Do the order by bit loop through and hold the type id in a variable.
    If on the next pass the type changes create a new table otherwise add to the current table.


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    Grand Rapids, MI
    Posts
    166
    Thank you!

Posting Permissions

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



Click Here to Expand Forum to Full Width