Help with macro

C

C Tate

I am trying to devise a macro that will go through all the tables in my
database and delete all the rows for a given 'project name'. Can anybody
offer any assistance with this? I don't know any vba and suspect it is
beyond the capabilities of the recorder.
 
T

Tom Wickerath

Access does not offer the ability to record a macro, like that found in the other Office
products.

You should simply create the appropriate SELECT query, with a criteria that filters the recordset
for your given project name. Once you are satisfied that the correct records are being returned,
you can convert this into a DELETE query in query design view, using the menu item Query > Delete
Query.

If you really must use a macro, then you can specify the name of your delete query there. Suggest
that you make a backup of either your table within the local database, or the entire database,
before running an action query of any kind, especially if this is new territory for you.

Tom
_______________________________


I am trying to devise a macro that will go through all the tables in my
database and delete all the rows for a given 'project name'. Can anybody
offer any assistance with this? I don't know any vba and suspect it is
beyond the capabilities of the recorder.
 
L

Larry Daugherty

The longer term solution might be to enforce Referential Integrity with
"Allow Cascading Delete" enabled. That way, when you try to delete the main
record in tblProject you'll be warned that you're about to delete many other
records as well. Answer yes and it will do the job for you.

HTH
 
C

C Tate

So do I understand this correctly? I can delete all the necessary rows from
ALL the tables using a query and then turning it into a delete query?

I am not totally sure how I would design this. I would have to drag in every
table to the design grid?
 
T

Tom Wickerath

Likely, yes. However, without knowing the specifics of your database design (for example, have
you included referential integrity between tables) it is difficult, at best, to provide a
definitive answer.

The best way to answer this question is for you to practice on a *copy* of your database. Post
questions as they arise, making sure to give enough detail that others will stand a reasonable
chance of being able to answer your questions. This would include the names of the tables and
fields in each table.

Tom
__________________________________


So do I understand this correctly? I can delete all the necessary rows from ALL the tables using
a query and then turning it into a delete query?

I am not totally sure how I would design this. I would have to drag in every table to the design
grid?
__________________________________


The longer term solution might be to enforce Referential Integrity with "Allow Cascading Delete"
enabled. That way, when you try to delete the main record in tblProject you'll be warned that
you're about to delete many other records as well. Answer yes and it will do the job for you.

HTH
--
-Larry-
--

__________________________________


Access does not offer the ability to record a macro, like that found in the other Office
products.

You should simply create the appropriate SELECT query, with a criteria that filters the recordset
for your given project name. Once you are satisfied that the correct records are being returned,
you can convert this into a DELETE query in query design view, using the menu item Query > Delete
Query.

If you really must use a macro, then you can specify the name of your delete query there. Suggest
that you make a backup of either your table within the local database, or the entire database,
before running an action query of any kind, especially if this is new territory for you.

Tom
_______________________________


I am trying to devise a macro that will go through all the tables in my database and delete all
the rows for a given 'project name'. Can anybody offer any assistance with this? I don't know any
vba and suspect it is beyond the capabilities of the recorder.
 
Top