参考:
Dim Adocon As New ADODB.Connection
Private Sub Form_Load()
Adocon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Password=;Data Source=" & App.Path & "\Test.mdb;Persist Security Info=True"
Adocon.CommandTimeout = 120
Adocon.Open
If SQLExistTable(Adocon, "newTestTable") Then
MsgBox "存在"
Else
MsgBox "不存在"
Adocon.Execute ("select * into newTestTable from TestTable") '复制
End If
Adocon.Close
Set Adocon = Nothing
End Sub
'判断表是否存在
Public Function SQLExistTable(cn As Connection, strTable As String) As Boolean
Dim strSQL As String
Dim Rs As New ADODB.Recordset
'Dim dbname As String
Dim bTemp As Boolean
On Error GoTo errSQLExist
'strSQL = "select counttable=count(*) from temp where name='" & strTable & "'"
'rs.Open strSQL, cn
Set Rs = cn.OpenSchema(adSchemaTables)
Do Until Rs.EOF
If Rs!Table_name = strTable Then
bTemp = True
Exit Do
Else
bTemp = False
End If
Rs.MoveNext
Loop
SQLExistTable = bTemp