PC Review


Reply
Thread Tools Rate Thread

Deleting table in another database

 
 
Mark
Guest
Posts: n/a
 
      30th Jun 2004
Is it possible to delete a table via code in another mdb,
and is so, could someone please provide me or point me in
the direction of some sample code to do this.

Thanks in advance.

Mark
 
Reply With Quote
 
 
 
 
Marshall Barton
Guest
Posts: n/a
 
      30th Jun 2004
Mark wrote:

>Is it possible to delete a table via code in another mdb,
>and is so, could someone please provide me or point me in
>the direction of some sample code to do this.



You have to use OpenDatabase to get to the other database's
TableDefs collection:

Dim dbOther As DAO.Database
Set dbOther = OpenDatabase("path to other mdb file")
dbOther.TableDefs.Delete "nameoftable"
dbOther.Close
Set dbOther = Nothing

--
Marsh
MVP [MS Access]
 
Reply With Quote
 
Mark
Guest
Posts: n/a
 
      30th Jun 2004
Marsh,

Thanks for the help. To expand on that, how do I
manipulate/create a primary key then in a table in
another db.

Maybe it would be easier if I explained what I'm trying
to do. Currently I'm pulling down 1/2 million+ records
from an Oracle server. In doing so, I can pull the
records if I use a Make Table query, but I get an ODBC
error when I use an Append query.

To get around this, I created a temporary table and then
appended the records from there to my indexed table. But
I bulk at running two queries, when I should be able to
do it in one.

So what I was thinking of doing was deleting the indexed
table, running the Make table query and then creating the
indexes and primary keys again.

Any thought's?

Thanks again.

Mark


>-----Original Message-----
>Mark wrote:
>
>>Is it possible to delete a table via code in another

mdb,
>>and is so, could someone please provide me or point me

in
>>the direction of some sample code to do this.

>
>
>You have to use OpenDatabase to get to the other

database's
>TableDefs collection:
>
>Dim dbOther As DAO.Database
>Set dbOther = OpenDatabase("path to other mdb file")
>dbOther.TableDefs.Delete "nameoftable"
>dbOther.Close
>Set dbOther = Nothing
>
>--
>Marsh
>MVP [MS Access]
>.
>

 
Reply With Quote
 
Marshall Barton
Guest
Posts: n/a
 
      30th Jun 2004
Mark wrote:
>Thanks for the help. To expand on that, how do I
>manipulate/create a primary key then in a table in
>another db.
>
>Maybe it would be easier if I explained what I'm trying
>to do. Currently I'm pulling down 1/2 million+ records
>from an Oracle server. In doing so, I can pull the
>records if I use a Make Table query, but I get an ODBC
>error when I use an Append query.
>
>To get around this, I created a temporary table and then
>appended the records from there to my indexed table. But
>I bulk at running two queries, when I should be able to
>do it in one.
>
>So what I was thinking of doing was deleting the indexed
>table, running the Make table query and then creating the
>indexes and primary keys again.



I know nothing about Oracle stuff so I may not be any help,
but I don't see how an append can fail when a make table
succeeds unless there is an index violation or a data type
mismatch. I would try to do the append by hand (from the
File - Import menu) to see if I could get more info on
what's going wrong. The reason I wouldn't jump into
recreating the indexes immediately is because you'll likely
get the same violation adding the indexes as you're getting
with the append query.

In any case, you can Execute an ALTER TABLE query with a
CONSTRAINT clause to recreate the indexes. Check Help for
SQL DDL statements for details. Or alternatively, you can
use the DAO CreateIndex method.
--
Marsh
MVP [MS Access]



>>-----Original Message-----
>>Mark wrote:
>>
>>>Is it possible to delete a table via code in another

>mdb,
>>>and is so, could someone please provide me or point me

>in
>>>the direction of some sample code to do this.

>>
>>
>>You have to use OpenDatabase to get to the other

>database's
>>TableDefs collection:
>>
>>Dim dbOther As DAO.Database
>>Set dbOther = OpenDatabase("path to other mdb file")
>>dbOther.TableDefs.Delete "nameoftable"
>>dbOther.Close
>>Set dbOther = Nothing
>>
>>--
>>Marsh
>>MVP [MS Access]
>>.
>>


 
Reply With Quote
 
Mark
Guest
Posts: n/a
 
      30th Jun 2004
Marsh,

Thanks again, as for the problem appending to a table
with Oracle, I sent several days trying to resolve the
issue with no success. The message I was getting was
record deleted, which doesn't make sense for the table I
was pulling from, but hey that's Oracle.

Have a great weekend.

Mark

>-----Original Message-----
>Mark wrote:
>>Thanks for the help. To expand on that, how do I
>>manipulate/create a primary key then in a table in
>>another db.
>>
>>Maybe it would be easier if I explained what I'm trying
>>to do. Currently I'm pulling down 1/2 million+ records
>>from an Oracle server. In doing so, I can pull the
>>records if I use a Make Table query, but I get an ODBC
>>error when I use an Append query.
>>
>>To get around this, I created a temporary table and

then
>>appended the records from there to my indexed table.

But
>>I bulk at running two queries, when I should be able to
>>do it in one.
>>
>>So what I was thinking of doing was deleting the

indexed
>>table, running the Make table query and then creating

the
>>indexes and primary keys again.

>
>
>I know nothing about Oracle stuff so I may not be any

help,
>but I don't see how an append can fail when a make table
>succeeds unless there is an index violation or a data

type
>mismatch. I would try to do the append by hand (from the
>File - Import menu) to see if I could get more info on
>what's going wrong. The reason I wouldn't jump into
>recreating the indexes immediately is because you'll

likely
>get the same violation adding the indexes as you're

getting
>with the append query.
>
>In any case, you can Execute an ALTER TABLE query with a
>CONSTRAINT clause to recreate the indexes. Check Help

for
>SQL DDL statements for details. Or alternatively, you can
>use the DAO CreateIndex method.
>--
>Marsh
>MVP [MS Access]
>
>
>
>>>-----Original Message-----
>>>Mark wrote:
>>>
>>>>Is it possible to delete a table via code in another

>>mdb,
>>>>and is so, could someone please provide me or point

me
>>in
>>>>the direction of some sample code to do this.
>>>
>>>
>>>You have to use OpenDatabase to get to the other

>>database's
>>>TableDefs collection:
>>>
>>>Dim dbOther As DAO.Database
>>>Set dbOther = OpenDatabase("path to other mdb file")
>>>dbOther.TableDefs.Delete "nameoftable"
>>>dbOther.Close
>>>Set dbOther = Nothing
>>>
>>>--
>>>Marsh
>>>MVP [MS Access]
>>>.
>>>

>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
deleting a table in an other database =?Utf-8?B?cmFmaWs=?= Microsoft Access VBA Modules 2 13th Aug 2007 06:14 PM
Deleting rows in Access database table =?Utf-8?B?TWFyaw==?= Microsoft Dot NET 6 26th Apr 2005 02:51 PM
Deleting table in external database. JohnH Microsoft Access External Data 0 13th Nov 2003 01:41 PM
Deleting a table in another database Miguel Velez Microsoft Access VBA Modules 2 30th Oct 2003 08:52 PM
Trouble deleting linked table from Access 2002 database Mark Microsoft Access Database Table Design 2 19th Oct 2003 07:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:02 PM.