# Re: 再想问一下.

Posted by Fai on August 27, 1999 at 14:31:11:

In Reply to: 再想问一下. posted by kkcheung on August 27, 1999 at 13:06:23:

: : : 我想在同一个mdb内,copy 其中一个资料表,存成另一个名称,可以点做.先谢谢.

: : Private Sub Command1_Click()
: : Dim db As Database
: : Dim rs As Recordset

: : Set db = DBEngine.Workspaces(0).OpenDatabase(资料库档名)
: : db.Execute "select * into 资料表2 from 资料表1"
: : End Sub
: : 资料表２不要事先建立!!!

: 如果我每日也执行db.Execute "select * into 资料表2 from 资料表1"
: 是否先要delete之前的资料表2.可应用什么语法?先谢谢你的回覆.

我就用query来做经常update的资料,看看有无用!
SQL = "select * into 资料表2 from 资料表1"
Set Db = OpenDatabase(varDBName)
For Each QDLoop In Db.QueryDefs
If QDLoop.Name = varQueryName Then
Db.QueryDefs.Delete QDLoop.Name
End If
Next QDLoop
Set QD = Db.CreateQueryDef(varDBName, SQL)
QD.Close
Db.Close

Follow Ups: