Results 1 to 4 of 4

Thread: Duplicate empty recordset

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 1999
    Posts
    80

    Post

    Hi,

    How do I make a copy of a recordset with just the field names in it without any data?

    I tried the Clone method but it does not seems to work with a declared recordset and a recordset from a Data control.

    This is the code I used:

    Dim rs as Recordset
    set rs.Clone = Data1.Recordset

    Thanks in advance.

  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    Code:
    Dim fld As DAO.Field
        Dim tbl As DAO.TableDef
        
        Set tbl = New TableDef
        
        For Each fld In Data1.Recordset.Fields
            
            tbl.Fields.Append tbl.CreateField(fld.Name, fld.Type, fld.Size)
            
        Next fld
        
            
        MsgBox tbl.Fields.Count
    I don't know what you want to do with the tabledef afterwards, but there it is!

    Tom

  3. #3
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105

    Post

    select *
    insert into output_tbl
    from input_tbl
    where 1=0


    works in SQL Server

  4. #4
    Addicted Member pardede's Avatar
    Join Date
    Jan 2000
    Posts
    232

    Post

    just a little modification to hausmann's suggestion, the code find VB-sql is:

    SELECT * INTO outputtable
    FROM inputtable WHERE False

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