Results 1 to 4 of 4
  1. #1
    e.badin is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2011
    Posts
    16

    Lightbulb Filter a table's columns

    Hello all,

    I come yet again with a brain puzzleing problem (for me at least).

    Sooo.... I have this table that gets created after reading a TXT file line by line. The reason I do it so is because the column names from my table always change.

    Now, there are 3 columns in this table that stay the same, and the rest 100 columns (yes, I know, 100) that are consecutive dates.

    Ex:


    Columns: X,Y,Z, Mon_4_14,Tue_4_15...... etc

    What I want is to be able is to create another table based on the original one but with only, let's say 20 consecutive days.

    What I need is an idea on how to loop through checking the column names, and filter them in a "select into" query.

    Thank you!

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    The consecutive date fields are an example of repeating groups which indicates that your database is not normalized. Each should be a record in table not a field. If each were a record, it would be easy to create a query to get the data you want.

  3. #3
    e.badin is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2011
    Posts
    16
    I am perfectly aware of that. The question still stands.

  4. #4
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    This code snippet from Allen Browne's site shows how to get the field names of a table

    Code:
    Function ShowFields(strTable As String)
        'Purpose:   How to read the fields of a table.
        'Usage:     Call ShowFields("Table1")
        Dim db As DAO.Database
        Dim tdf As DAO.TableDef
        Dim fld As DAO.Field
        
        Set db = CurrentDb()
        Set tdf = db.TableDefs(strTable)
        For Each fld In tdf.Fields
            Debug.Print fld.Name, FieldTypeName(fld)
        Next
        
        Set fld = Nothing
        Set tdf = Nothing
        Set db = Nothing
    End Function
    You say you want to create another table using the field names, but do you want to create records with the dates (of the field names) or do you want a table with the same field names just a subset of the original?

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

Similar Threads

  1. Me not picking up new columns in table
    By asterismw in forum Programming
    Replies: 3
    Last Post: 03-11-2011, 02:00 PM
  2. Deleting empty columns from a table
    By kapil0712 in forum Programming
    Replies: 3
    Last Post: 05-17-2010, 12:35 AM
  3. Table with look-up columns
    By Tallica in forum Database Design
    Replies: 3
    Last Post: 03-02-2010, 02:09 PM
  4. Replies: 3
    Last Post: 01-21-2010, 08:10 PM
  5. Replies: 1
    Last Post: 10-09-2009, 11:52 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