compact and repair through a VB code

P

Pietro

Hi,
I have a probem that my database canot be compacted and repaired while
it's being used by users,so i'm trying to write the below code on the on time
event to do compact and repair at 2:30 am when all users had already closed
the application,but i get a message that says that i cannot compact and
repair my database through a VB code or through a macro,instead i should go
to toos>dtabase utilities...ecc. do suggest something?

If Time() > "2:30:00 AM" And Time() < "2:30:06 AM" Then
DoCmd.RunCommand acCmdCompactDatabase
End If
 
K

Krzysztof Pozorek [MVP]

U¿ytkownik "Pietro said:
Hi,
I have a probem that my database canot be compacted and repaired while
it's being used by users,so i'm trying to write the below code on the on
time
event to do compact and repair at 2:30 am when all users had already
closed
the application,but i get a message that says that i cannot compact and
repair my database through a VB code or through a macro,instead i should
go
to toos>dtabase utilities...ecc. do suggest something?

If Time() > "2:30:00 AM" And Time() < "2:30:06 AM" Then
DoCmd.RunCommand acCmdCompactDatabase
End If

What version of Access? You may use something like this:
CommandBars.FindControl(id:=2071).accDoDefaultAction
But it doesn't work in MsAccess 2007 (previous versions only).

Krzysztof Pozorek, MVP,Poland
www.access.vis.pl
 
P

Pietro

Thanx Krzysztof Pozorek for your reply...
Most of the users are using Access 2007,I tried the below code but i still
get the same message.
Please advise...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top