Results 1 to 3 of 3

Thread: add fields to table from recordset

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2001
    Posts
    19

    Arrow add fields to table from recordset

    I have two tables with the exact same structure, one table has customer info. in it and the other one is empty. What I have done is created a recordset to hold info from the customer table based on search material supplied by the client. I now want to be able to fill in all the selected records to the temp table but would like to do it without having to list every field in an Insert Into statement because there are like 50 fields.
    Can I some how make a statement like "Insert Into tempTable * objrs" because I'm going to be filling in every field.

    This would be so much more easier, and I'm sure its possible, but I can't figure it out.

    Thanks...

  2. #2
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    You can do something like the following:
    Code:
    Dim objField         As ADODB.Field  'or just "Field" if DAO
    Dim strFieldName As String
    Do Until Recordset1.EOF
        For Each objField In Recordset1.Fields
            strFieldName = objField.Name
            Recordset2.AddNew
            Recordset2.Fields(strFieldName).Value = objField.Value
        Next
        Recordset2.Update
        Recordset1.MoveNext
    Loop
    "It's cold gin time again ..."

    Check out my website here.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2001
    Posts
    19
    Thanks Bruce but I wanted to know if there was a sql statement that I could use. I already knew how to do it with a recordset object, but I'd like to avoid creating another one if possible.

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