|
-
Apr 6th, 2001, 05:50 AM
#1
Thread Starter
Hyperactive Member
How do I delete a table from a access database. I am using DAO.
I have a number of tables in the database, "Rev 0","Rev 1" etc.. I have tried the following code but it does'nt work
Code:
Dim db As Database
Dim rs As Recordset
Set db = OpenDatabase(App.path & "\Crr_data\" & ListView2.SelectedItem.text & "\valve.mdb")
Set rs = db.OpenRecordset(ListView5.SelectedItem.text, dbOpenDynaset)
rs.Delete ' goes wrong here
db.Close
I get the message "No current record"
Any ideas?
Cheers
-
Apr 6th, 2001, 07:10 AM
#2
Fanatic Member
You can either use the TableDefs collection Delete method or use the DROP TABLE TableName SQL syntax. Remember to refresh the collection or the database window.
Check Access help for those.
Cheers,
P.
Not nearly so tired now...
Haven't been around much so be gentle...
-
Apr 6th, 2001, 08:16 AM
#3
Thread Starter
Hyperactive Member
Cheers Paul,
I`ve tried doing it with the tabledefs but I still cant get it to work, have you got short examples, I think I am getting the syntax wrong
Cheers
Rick
-
Apr 6th, 2001, 11:12 AM
#4
Fanatic Member
Dunno what happened to Paul, I had lunch with him and he's gone all quiet... 
Anyway, try this:
Code:
Dim db As Database
Set db = OpenDatabase(App.Path & "\Crr_data\" & ListView2.SelectedItem.Text & "\valve.mdb")
db.TableDefs.Delete ListView5.SelectedItem.Text
-
Apr 6th, 2001, 11:37 AM
#5
Fanatic Member
Really, use DROP TABLE - its easier and more portable, but if you must.
Code:
Dim db As Database
Set db = CurrentDb
db.TableDefs.Delete "MyTable"
db.TableDefs.Refresh
Set db = Nothing
Cheers,
P.
Not nearly so tired now...
Haven't been around much so be gentle...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|