how to delete an object in another db

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

Could anyone tell me if its possible to delete an object such as a table,
form, query etc in another database, and if so how is it done?

Thanks for any help.
 
Hi

Could anyone tell me if its possible to delete an object such as a table,
form, query etc in another database, and if so how is it done?

Thanks for any help.

Use the OpenDatabase Method to get a pointer to the 'external'
database. You
could the DeleteObject Method to delete a form.
 
Wez.k said:
Hi

Could anyone tell me if its possible to delete an object such as a table,
form, query etc in another database, and if so how is it done?

Thanks for any help.

Wez,

For tables you can open the database and use a drop table SQL statement,
something like this (untested):

Dim MyDB as DAO.Database

Set MyDB=OpenDatabase(<DB Path Here>)

MyDB.Execute "DROP TABLE <Table Name Here>;", dbFailOnError

MyDB.Close
Set MyDB=Nothing

Not sure about forms, reports etc.

Ed Metcalfe.
 
Wez.k said:
Could anyone tell me if its possible to delete an object such as a table,
form, query etc in another database, and if so how is it done?


Open the other mdb file and operate on its db object

Dim otherDb As Database
Set otherDb = OpenDatabase("path to other mdb file")

otherDb.TableDefs,Delete "sometable"
 
Ed Metcalfe said:
Wez,

For tables you can open the database and use a drop table SQL statement,
something like this (untested):

Dim MyDB as DAO.Database

Set MyDB=OpenDatabase(<DB Path Here>)

MyDB.Execute "DROP TABLE <Table Name Here>;", dbFailOnError

MyDB.Close
Set MyDB=Nothing

Not sure about forms, reports etc.

Ed Metcalfe.


Many thanks, this works fine for tables but as you suspected not for the other objects. If possible I need to be able to delete forms, queries and reports too.
 
OldPro said:
Use the OpenDatabase Method to get a pointer to the 'external'
database. You
could the DeleteObject Method to delete a form.

Thanks for your reply. However I cant find anything in the help files for the OpenDatabase Method. Could you tell me how to implement this?
 
Marshall Barton said:
Open the other mdb file and operate on its db object

Dim otherDb As Database
Set otherDb = OpenDatabase("path to other mdb file")

otherDb.TableDefs,Delete "sometable"
Thanks for your reply. However there seems to be a syntax error with the
TableDefs line because the code window is showing it in red. Also, will this
method work for forms, queries and reports?
 
Wez.k said:
Thanks for your reply. However there seems to be a syntax error with the
TableDefs line because the code window is showing it in red. Also, will this
method work for forms, queries and reports?

I don't see what you tried, so I can't spot any syntax
errors.

The Delete method will also work for queries, but not for
forms or reports.

It might be better if you used Automation so you can employ
SelectObject and DeleteObject.

OTOH, This is starting to sound like an attempt to update an
existing database with modified forms, reports, etc. If so,
it is not a good idea. Instead you should distribute a new
front end mdb and use SQL DDL statements to modify the
backend tables.
 
Douglas said:
Slight typo. Marsh put comma Delete rather than period Delete.


Oh my. I have to enlarge my font - again. It's getting
difficult to see the difference.

Thanks for catching that Doug.
 
Thanks for your help everyone and sorry if I've wasted your time. Having
banged my head on it for a couple of days, I have now realised that I dont
have to do this at all, there's a much simpler way of achieving what I want
to do and I already know how to do it! Sometimes I cant see the wood for the
trees...

Regards.
 
Back
Top