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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prohibit use of db until 8:00 am for maintenance 1

Status
Not open for further replies.

dbero

Technical User
Mar 31, 2005
109
US
I frequently need to compact and repair databases between 7 and 8 am. therefore, i need everybody out of the db. I have put the code below together to force people out, but when I am compacting, this allows the user into the db and would prevent compact from working.

Does anyone know a way to put this type of code into a cmd file that would prevent the db from ever opening when ran? Or is there another way to keep users out until i'm done repairing?

thanks!


Dim CurrentTime
CurrentTime = Time
Dim StartTime
StartTime = #8:00:00 AM#

If CurrentTime < StartTime Then
MsgBox ("too early to use db. Try after 8:00")
Application.Quit acSaveYes
End If
 
A quick way would be to check the option to open the database exclusively (not shared) while you compact.
Go to Tools|Options|Advanced and check "exclusive" on the "Default Open Mode" option group.

I have great faith in fools; self-confidence my friends call it.
-Poe
 
Is it possible for you to use a Script (vbs) file? If so, you can set the shortcut to your application to the script file, which will control the opening of the application:

[tt]Option Explicit
Dim WSHShell

If Time()<#08:00:00# then
Msgbox "Please try again after 8:00am"
Else
Set WSHShell = CreateObject("WScript.Shell")
WSHShell.Run """C:\Program Files\Microsoft Office\Office\MSACCESS.EXE"" ""C:\Doc Files\Tek-Tips.mdb"""
End If[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top