PDA

Click to See Complete Forum and Search --> : Duplicate empty recordset


cedx
Jan 18th, 2000, 07:45 AM
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.

Clunietp
Jan 19th, 2000, 01:53 PM
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

JHausmann
Jan 20th, 2000, 08:27 AM
select *
insert into output_tbl
from input_tbl
where 1=0


works in SQL Server

pardede
Jan 25th, 2000, 03:44 AM
just a little modification to hausmann's suggestion, the code find VB-sql is:

SELECT * INTO outputtable
FROM inputtable WHERE False