0

I had a MS Access application that is used in multiuser environment. I want to make maintanence every thursday between 15:00 and 16:00. At this point I have two issues to consider.

Firstly, The users who may be entering to application before 15:00.
Secondly, the users who will be entering between 15:00-16:00

For the second scenario, I need to prevent my users to access the MS Access application. For this purpose, I have written the following code into the load event of my beginning form.

Private Sub Form_Load()
MsgBox "Between 15.00 and 16.00 on Thursdays access is not available due to maintenance", vbOKOnly*  
DoCmd.CloseDatabase
End Sub

It worked in a way I would like. The only thing is now to restrict it to work between specific hours as I described. How can I integrate time parameter to my code?

And for first scenario, For all users in the system wherever they are, close database function should be working and Application should be closed automatically.

June7
  • 19,874
  • 8
  • 24
  • 34
Dman
  • 11
  • Does this answer your question? [Force all users to disconnect from 2010 Access backend database](https://stackoverflow.com/questions/10905680/force-all-users-to-disconnect-from-2010-access-backend-database) – June7 Jan 24 '21 at 21:42
  • Why not run maintenance midnight Saturday? – June7 Jan 24 '21 at 21:54
  • I do not want to work on weekend. I will be the person who will do necessary updates and maintanence :) – Dman Jan 26 '21 at 21:40

1 Answers1

0

To check for time period:

Dim T As Date
T = Time()
If Weekday(Date()) = 5 And T >= #3:00:00 PM# And T <= #4:00:00 PM# Then

Forcing a db to close risks corrupting data but I suppose it can be done. This is a common topic and should be able to find many examples.

June7
  • 19,874
  • 8
  • 24
  • 34