Auto close database or Forms

prabhu

Registered User.
Local time
Today, 14:21
Joined
Apr 21, 2010
Messages
54
Hello all,

I take my database backup every one hour for some critical reasons and during that time i want the close the database from all the users. When i googling i found the below code but i dont know how can i modify this to run for every one hour and where to place this query in my database...


Private Sub Form_Timer()
If (Time() >= #6:26:00 AM# And Time() <= #6:29:00 AM#) Then
MsgBox "System Maintenance On-going. Please check back after 3 minutes.", vbOKOnly
DoCmd.Quit acQuitSaveAll
End If
End Sub

I am brand new to Access...Your help greatly appreciated...
 
Something along the lines of:-


Code:
If (Time() >= #6:26:00 AM# And Time() <= #6:29:00 AM#) Then
MsgBox "System Maintenance On-going. Please check back after 3 minutes.", vbOKOnly
DoCmd.Quit acQuitSaveAll
ElseIf (Time() >= #7:26:00 AM# And Time() <= #7:29:00 AM#) Then
MsgBox "System Maintenance On-going. Please check back after 3 minutes.", vbOKOnly
DoCmd.Quit acQuitSaveAll
ElseIf (Time() >= #8:26:00 AM# And Time() <= #8:29:00 AM#) Then
MsgBox "System Maintenance On-going. Please check back after 3 minutes.", vbOKOnly
DoCmd.Quit acQuitSaveAll
'etc etc
End If

should be placed in all of your forms Timer events
 
thank you for helping me...
its working fine.
 
Something along the lines of:-


Code:
If (Time() >= #6:26:00 AM# And Time() <= #6:29:00 AM#) Then
MsgBox "System Maintenance On-going. Please check back after 3 minutes.", vbOKOnly
DoCmd.Quit acQuitSaveAll.....
...Truncated to save space

should be placed in all of your forms Timer events
Wow, very inefficient code. How about modifying so it is much smaller:
Code:
Select Case Format(Now(),"nn")
   Case 26 To 29
      MsgBox "System Maintenance On-going. Please check back after 3 minutes.", vbOKOnly
   Application.Quit acQuitSaveNone
End Select
Oh, and by the way, the acQuitSaveAll is NOT good to use because that saves DESIGN CHANGES and has NOTHING to do with records.
 
I take my database backup every one hour for some critical reasons and during that time i want the close the database from all the users.
Nothing personal, but I'd hate to be one of your users. That is a horrendous thing to shut them down every hour. You really should do something that doesn't require this.

Is there a reason why you can't use SQL Server or SQL Server Express instead?
 
Wow, very inefficient code. How about modifying so it is much smaller:

It wasn't my code, I just showed him how he could use the code he provided to achieve the result he wanted.

I do agree however that I would not like to be a user of this system and be kicked out every hour.

Select Case Format(Now(),"nn")
Case 26 To 29
MsgBox "System Maintenance On-going. Please check back after 3 minutes.", vbOKOnly
Application.Quit acQuitSaveNone
End Select

If changing to use this code then either the 29 should be replaced with 28 or the message displayed should be changed to ask the user to check back after 4 minutes as this code will boot them out at any time between hh:26:00 and hh:29:59 which is 4 minutes
 
Last edited:
dbDamo & boblarson,

than you so much for both of your inputs. Its really helped me a lot.

Boblarson, i agree your point. I dont have any option with me since its a very much critical data. there may be some otherways to do this as you said. But i am not familiar with this, all i know is very basics of MS access.
But i would like to take your support. I am preparing the data flow diagram which i will sned it to you, hope with that you can help me to optimise this when you find time...:)
Thanks once again...:)
 

Users who are viewing this thread

Back
Top Bottom