By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,731 Members | 1,123 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,731 IT Pros & Developers. It's quick & easy.

drop Microsoft Access XP table with Visual Basic

P: n/a
Dear developer,
I have an error message when I try to delete or drop Microsoft Access XP
table with ADOX in Visual Basic 6. I use the ADOX.Catalog and ADOX.table to
create and delete or drop table within Visual Basic program.
If anybody knows how to solve the problem, please give me the solution.
I would like to thank you for your attention and response.

Best regard,

Sanad
Jul 21 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
delete table with Visual Basic 6 wrote:
Dear developer,
I have an error message when I try to delete or drop Microsoft Access
XP table with ADOX in Visual Basic 6. I use the ADOX.Catalog and
ADOX.table to create and delete or drop table within Visual Basic
program.
If anybody knows how to solve the problem, please give me the
solution.
I would like to thank you for your attention and response.


Hello,
What's the error message you're getting?
Jul 21 '05 #2

P: n/a
Hi,

This is a wrong newsgroup for vb 6 (this is *dotnet*).
Anyway, what error do you get?
Maybe the table in question is referenced by another table and thus can't be
dropped?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
SLODUG - Slovene Developer Users Group
www.rthand.com

"delete table with Visual Basic 6" <delete table with Visual Basic
6@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
Dear developer,
I have an error message when I try to delete or drop Microsoft Access XP
table with ADOX in Visual Basic 6. I use the ADOX.Catalog and ADOX.table
to
create and delete or drop table within Visual Basic program.
If anybody knows how to solve the problem, please give me the solution.
I would like to thank you for your attention and response.

Best regard,

Sanad

Jul 21 '05 #3

P: n/a
My error message is "Run time error '3265': Item cannot be found in the
collectioin corresponding to the requested name or ordinal". But when I check
my database, the table to be deleted is exist. And also the name is excactly
the same with the value of the variable DelCodeNumber.
Here is the code:
Dim catStok As New ADOX.Catalog
Dim tblStok As New ADOX.Table

catStok.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" &
"Data Source=C:\dbStok.mdb;"
tblStok.Name = DelCodeNumber
catStok.Tables.Delete tblStok
Set catStok.ActiveConnection = Nothing
Set catStok = Nothing

Thank you very much for your attention

Best Regard,

Sanad
"Leon Mayne [MVP]" wrote:
Hello,
What's the error message you're getting?


Jul 21 '05 #4

P: n/a
delete table with Visual Basic 6 wrote:
Dim catStok As New ADOX.Catalog
Dim tblStok As New ADOX.Table

catStok.ActiveConnection =
"Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\dbStok.mdb;"
tblStok.Name = DelCodeNumber
catStok.Tables.Delete tblStok
Set catStok.ActiveConnection = Nothing
Set catStok = Nothing


Have you stepped through to check the value of DelCodeNumber to make sure
it's correct?
Jul 21 '05 #5

P: n/a
I have stepped through to check the value of DelCodeNumber, and the value I
use is "1", because indeed the table name I create in the database is a kind
of code number, like "1" , "12" , "25", "314", etc.
So the value of variable DelCodeNumber is "1", not "1.tbl". I had use the
"1.tbl" but the result is the same.

catStok.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" &
"Data Source=C:\dbStok.mdb;"
tblStok.Name = NoKodeDel + ".tbl"

catStok.Tables.Delete tblStok --> Here the program stop running

Set catStok.ActiveConnection = Nothing
Set catStok = Nothing

I use Visual Basic 6 within Visual Studio 6 Enterprise Edition, and Ms
Access XP.
If you have a better or another way just to delete / drop Ms Access XP table
with Visual Basic 6, let me know. Or may be have I to use Ms Access 97 and
use DAO ?

Thank you very much for your attention.

"Leon Mayne [MVP]" wrote:
Have you stepped through to check the value of DelCodeNumber to make sure
it's correct?

Jul 21 '05 #6

P: n/a
Finally, I get the answer!!!
I get the answer in the Visual Basic-database.ado section in this newsgroup
date 4/1/2005 by Brendan Reynolds.
Thank you again for Mr.Brendan Reynolds.

The answer is:

"If the function returns True, call Catalog.Tables.Delete YOURTABLENAME to
delete the table."

My mistake is

Dim tblStok As New ADOX.Table

tblStok.Name = DelCodeNumber
Catalog.Tables.Delete tblStok --> error

Catalog.Tables.Delete DelCodeNumber --> correct

By the way, I appreciate Mr. Leon Mayne for the VERY FAST attention and
answer. And also thank you for Mr.Miha Markic for the advice and forgiveness.

All right, have a nice work. Your work means a lot for us.

Best regard,

Sanad
Jul 21 '05 #7

P: n/a
delete table with Visual Basic 6 wrote:
Finally, I get the answer!!!


Glad you found the answer. Sorry I couldn't help earlier.
Jul 21 '05 #8

P: n/a
On Mon, 10 Jan 2005 02:15:04 -0800, "delete table with Visual Basic 6" <delete table with Visual
Basic 6@discussions.microsoft.com> wrote:

Dear developer,
I have an error message when I try to delete or drop Microsoft Access XP
table with ADOX in Visual Basic 6. I use the ADOX.Catalog and ADOX.table to
create and delete or drop table within Visual Basic program.
If anybody knows how to solve the problem, please give me the solution.
I would like to thank you for your attention and response.


BTW, you can also use Access SQL DDL:

DROP TABLE TableName
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Jul 21 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.