473,322 Members | 1,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

drop Microsoft Access XP table with Visual Basic

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
8 5637
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Novice | last post by:
Hi all, I am a C++ and Java developer with over 3 years of industry experience. I've written low level C++ code, in addition to web clients that use web services. I've just recently installed the...
8
by: WindAndWaves | last post by:
Hi everyone, Has anyone got any experience with drop and drag in Access? I would like to make a calendar style form where my users can drop and drag appointments.... I am using Access 2003...
3
by: Stephen Adam | last post by:
Hi there, I'm sure i'm missing something really simple here, all i want to do is get the value of the selected item in a list box. Even after much fiddling about last night I still could not get...
10
by: Geoff Jones | last post by:
Hi I'm trying to drop a table by using: Dim cmd As New OleDbCommand("DROP TABLE IF EXISTS books", myconnection) cmd.ExecuteNonQuery() but I get a syntax error: "Syntax error in DROP TABLE...
182
by: Jim Hubbard | last post by:
http://www.eweek.com/article2/0,1759,1774642,00.asp
8
by: delete table with Visual Basic 6 | last post by:
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...
2
by: shaznay2 | last post by:
I need some help! I'm trying to set up two drop down menus where the first displays the Department and the second displays the names of the printers found in the department. So far i have two...
5
by: Romulo NF | last post by:
Greetings, I´m back here to show the new version of the drag & drop table columns (original script ). I´ve found some issues with the old script, specially when trying to use 2 tables with...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.