Professional Documents
Culture Documents
DoCmd.SetWarnings False
DoCmd.SetWarnings True
End Sub
1. 'Using ADO
3. Private rs As ADODB.Recordset
6. 'PSI = "True" if there is a password to get into the database else "False"
7.
9.
10. 'MS SQL Server: ProviderType = "Provider=SQLOLEDB.1" & UserPassword & UserID
& ";Integrated Security=SSPI;Persist Security Info=" & PSI & ";Initial Catalog=" & Data
baseName & ";Data Source=" & ServerName
11.
13.
14. Oracle using MS provider: ProviderType = "Provider=OraOLEDB.Oracle.1" & UserID
& UserPassword & ";Data Source=" & ServerName & ";DistribTx=0"
15.
17.
21.
28. 'Put you code here using (tempSchema & "." & tempTable) as the table name
29. End If
30. rs.MoveNext
31. Loop
32.
38. 'Put you code here using (tempTable) as the table name
39. End If
40. rs.MoveNext
41. Loop
sql ="DROP TABLE IF EXIST" & <table_name by a textbox or msgbox or whatever>& "
rs.execute sql
Dim db as database
Set db=OpenDatabase("testing.mdb")
db.Execute "Delete From BadTable"
Sub Form_Load ()
Dim db As database
Dim tds As TableDefs
form1.Show ' Must Show form in Load event for Print to be visible.
form1.WindowState = 2 ' Maximize Form1 to make room for table list.
sourcedb = "c:\VB3\BIBLIO.MDB" ' Original master database.
destdb = "C:\TEST.MDB" ' Path to database with table to delete.
tabletodelete = "Authors"
FileCopy sourcedb, destdb ' Use copy of database; preserve original.
Set db = OpenDatabase(destdb)
Set tds = db.TableDefs ' Open the TableDefs collection.
' Display names of all tables in database:
For j = 0 To tds.Count - 1
Print tds(j).Name
Next
Print
' Delete a table. (This deletes the TableDef and all records):
tds.Delete tabletodelete
' or use: db.TableDefs.Delete tabletodelete
' If you want to delete all records and still preserve the TableDef
' table definition, use the following instead of the above Delete:
' db.Execute "Delete From " & tabletodelete
End Sub