Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to delete contents of table with relatioships...

Status
Not open for further replies.

adsfx

Programmer
Jun 4, 2003
237
GB
Hi,

am trying to find out how to delete all records of a table that has relationships so table can be used 'fresh'

this needs to be activated from a macro

nb cant delete table and copy template 'cos of relationships, is there a 'clear records' command?

MarkG
 
Mark,

In a table with a 1:M relationship, the records in the many side have to be deleted first. I hope that this is the correct type.

Go to your macro, choose RunSQL action and type
DELETE FROM [tablename];

This will delete every record from the table called tablename.
You may want to put SetWarnings False beforehand and SetWarnings True afterwards to stop Access' confirmation dialog coming up.


John
 
cheers john...better use with care!!

dont spose any ideas how to insert 4 blank records into a table at the end of each sorted 'category'

MarkG
 
To insert a record, you can use an Insert query

Insert into tablename (fieldname1, fieldname2, fieldname3)
values (value1, value2, value3).

You can run this from a RunSQL macro as well if you wish, or write it as code.

You don't have to include every field there - only mandatory ones (eg primary keys and those with the Required flag set to true).

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top