Make table based on criteria

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • syntaktik
    New Member
    • Dec 2009
    • 6

    Make table based on criteria

    I want to create a query that will append the information I select, and then place it in another table. That table should be created through a form so I can select how many fields there should be. So if I would select 3 form a combo box, it would give me these three columns: "Field1, Field2, Field3." Is this possible? The only way I know is the ALTER TABLE statement, but I have no clue how to use it.
    http://office.microsoft.com/en-us/ac...322071033.aspx.

    If anyone knows another way, I'd be glad to use it.
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    The following code will create a new table ...

    Code:
        strSQL = "SELECT field1, field2, field 3 " & _ 
                 "INTO NewTableName " & _
                 "FROM OriginalTableName"
        DoCmd.SetWarnings False
        DoCmd.RunSQL strSQL
        DoCmd.SetWarnings True
    Keep in mind you don't want to be creating a new table each time unless you overwrite the original table or delete it.

    Comment

    • syntaktik
      New Member
      • Dec 2009
      • 6

      #3
      I could reuse the same table again, but I may not fill in all the columns(fields? ). Is there a code to ignore them in the forms and reports based on that table?

      Comment

      • MMcCarthy
        Recognized Expert MVP
        • Aug 2006
        • 14387

        #4
        All you should need to do is use the same table name each time. This should overwrite the previous version of the table.

        Comment

        Working...