compact and repair through a VB code

  • Thread starter Thread starter Pietro
  • Start date Start date
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
 
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
 
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...
 
Back
Top