Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

vba code access

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » Vba code for access 2003 database 'compact and repair'

Vba code for access 2003 database 'compact and repair'

ResolvedVersion 2003

Russell has attended:
Access VBA course
Excel VBA Intro Intermediate course
Excel VBA Advanced course

Vba code for access 2003 database 'compact and repair'

Can you please provide code for automating the compact and repair database procedure? The aim would be to link this to an on-click exit form button event:-
1) close form 2) compact and repair database 3) copy database to a date stamped archive directory 4) close application

RE: vba code for access 2003 database 'compact and repair'

Hi Russell,

Thank you for your question and welcome to the forum.

Try this piece of code:

CommandBars("Menu Bar"). _
Controls("Tools"). _
Controls("Database utilities"). _
Controls("Compact and repair database..."). _
accDoDefaultAction

This code should be the equivalent to using the Tools menu.

I hope this helps.

Regards

Simon

RE: vba code for access 2003 database 'compact and repair'

Thanks Simon, appreciated :)

Thu 15 Dec 2011: Automatically marked as resolved.

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Access tip:

Deleting duplicate records from a table

You cannot delete records tables where there duplicate records. A way around this is to create a new table which wont hold the duplicates. and then deleting the old table.

1. Use a make-table query based on this table only. IMPORTANT - Ensure that you include all of the fields from your original table or you may loose data.

2. Open the query's property sheet by using VIEW, QUERY, PROPERTIES, and set the Unique Values property to Yes

3. Because you have selected the Unique Values to Yes when you run the query, Access creates a new table without duplicate records. You can now delete the old table and rename the new one.

View all Access hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.