Question Database Auto-closing on Required Time

shieriel

Registered User.
Local time
Tomorrow, 02:44
Joined
Feb 25, 2010
Messages
116
Hi to all. I just want to ask if there's a code of auto-closing for access db? For example the db will close every 2:00am. Because we have this database that needs to close for an update in the database.

Many thanks in advance.
 
Check your help file for Timer Interval and the On Timer event (hint: you'll need a form).
 
Hi shieriel!
I get my DB Backups every day after 3:00 pm so I wrote the code:

PHP:
If Not bBacked Then
    If IsLoaded("Adminstrator_F") Then
        If (Time() >= #3:00:00 PM# And Time() <= #3:15:00 PM#) Then
                Call BackupDB
                bBacked = True
        End If
    End If
End If

so your code should be something like this:

Code:
        If (Time() >= #2:00:00 AM# Then
                DoCmd.Quit acQuitSaveAll                
        End If

Call the code on timer event of the form.
Hope this help.
 
Hi Khalid. Thanks for your help! Regarding the back-up of your database, i also want to apply this on my database. But how can i start the back-up? Or is it automatically generated when i apply the code?

By the way, the database is being open in different computers via LAN network, do i have to apply the code on every computer or just on the main file only?

Many thanks in advance...
 
Hi Khalid. Thanks for your help! Regarding the back-up of your database, i also want to apply this on my database. But how can i start the back-up? Or is it automatically generated when i apply the code?

By the way, the database is being open in different computers via LAN network, do i have to apply the code on every computer or just on the main file only?

Many thanks in advance...

Hi,
you have to apply the code on all the computers. I guess you db is slipted with be and fe, and linked with back-end database? is it??
if any of your user keep open your database on the network. it is not possible to do anything with maintenance, because when the database is opened it will create a log file on the network drive and will lock the databae for designing modifying etc. so all the users should be out of the db.

I have my Administrator panel so all the users can be monitored for who is online to the database and from which pc and all or someone could be kicked out if necessary.

For backup the database you have to write another code to backup your database "Call BackupDB" calls the function which I wrote to backups my database to certain folder on my local machine. (this is not an Access built-in fuction)

Is your front End is in ACCDE format?
 
Khalid

You talk of an Adminstrator panel that monitors who is on the system. This is a large topic on this forum, especially being able to remotely disconnect them. From your thread it appears yours does. Could you possible post a sample to overview please.
 
Khalid

You talk of an Adminstrator panel that monitors who is on the system. This is a large topic on this forum, especially being able to remotely disconnect them. From your thread it appears yours does. Could you possible post a sample to overview please.

Yes! David I do have my Admin panel and can do with the users whatever needed. Its a big work to manage the users. Just have a look it the screen shot.

attachment.php
 

Attachments

  • Admin.JPG
    Admin.JPG
    99 KB · Views: 2,579
Hi,
you have to apply the code on all the computers. I guess you db is slipted with be and fe, and linked with back-end database? is it??
if any of your user keep open your database on the network. it is not possible to do anything with maintenance, because when the database is opened it will create a log file on the network drive and will lock the databae for designing modifying etc. so all the users should be out of the db.

I have my Administrator panel so all the users can be monitored for who is online to the database and from which pc and all or someone could be kicked out if necessary.

For backup the database you have to write another code to backup your database "Call BackupDB" calls the function which I wrote to backups my database to certain folder on my local machine. (this is not an Access built-in fuction)

Is your front End is in ACCDE format?



As i know the accde is for access2007 right? We only have access2003 format and we are not using accde. As i have checked for my database the computers on our network are only having shortcut fot the main file of databse. So maybe i just have to apply the code for the main file. I am still confused on how to backup my database. Can you give me some sample project or maybe link for db backup?
 
As i know the accde is for access2007 right?

Yes! accde is 2007 compiled front end format. In 2003 it is MDE.

We only have access2003 format and we are not using accde. As i have checked for my database the computers on our network are only having shortcut fot the main file of databse.

This mean all the users are pulling one single file from the network, which could produce problems in the future and your application will become slowdown. I suggest you to Split your database in back-end and front-end application.
you can apply the following code on a hidden form which should always open in the background. (or you can put the code on main form which is always open)

- create a form, open it on application startup (Autoexec macro is best place for initializing any settings)
- write the following code on form timer event
Code:
           If (Time() >= #2:00:00 AM# And Time() <= #2:30:00 AM#) Then
                 DoCmd.Quit acQuitSaveAll                
           End If

This code will check the time on timer event and will quite the database between 2:00am till 2:30am, there are more way to close the database automatically if user is not using it for some specific time interval. (my application gives alert message to users that application will automatically close in 5 minutes with the count down timer, if user is not working in application for 30 minutes or if the application is idol for 30 minutes)
automatic back is also achievable by some piece of coding, which will be later.
 
Last edited:
You are welcome

HI sir Khalid. I tried the code just now but nothing happens on my database. Still not auto-closing. I put the code on the "on timer" event. Please check my code if there is something wrong:
code:
Private Sub Form_Timer()
If IsLoaded("Switchboard1") Then
If (Time() >= #4:35:00 PM# And Time() <= #4:38:00 PM#) Then
DoCmd.Quit acQuitSaveAll
End If
End If
End Sub
 
Finally, after playing with the code and doing some searching on the forums i end-up with this code and it works fine:

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

Thanks to all of you that continuously helping beginners like me:D
 
Yes! David I do have my Admin panel and can do with the users whatever needed. Its a big work to manage the users. Just have a look it the screen shot.

attachment.php


Hello! Can you teach me how to do this, just the feature that will allow me to see their status realtime please? :o:o:o
 
Yes! accde is 2007 compiled front end format. In 2003 it is MDE.



This mean all the users are pulling one single file from the network, which could produce problems in the future and your application will become slowdown. I suggest you to Split your database in back-end and front-end application.
you can apply the following code on a hidden form which should always open in the background. (or you can put the code on main form which is always open)

- create a form, open it on application startup (Autoexec macro is best place for initializing any settings)
- write the following code on form timer event
Code:
           If (Time() >= #2:00:00 AM# And Time() <= #2:30:00 AM#) Then
                 DoCmd.Quit acQuitSaveAll                
           End If

This code will check the time on timer event and will quite the database between 2:00am till 2:30am, there are more way to close the database automatically if user is not using it for some specific time interval. (my application gives alert message to users that application will automatically close in 5 minutes with the count down timer, if user is not working in application for 30 minutes or if the application is idol for 30 minutes)
automatic back is also achievable by some piece of coding, which will be later.

Hello! This does not work for me... I have a bunch of other stuff that I need it to do before quitting the application. What should I do? I have attached my DB so you can check. Thanks in advance!
 

Attachments

Please note, you are posting to a thread that is 9 years old.

Can you please give a clear description of what you are attempting to do?
The "This does not work for me" can be understood in more than one context. Is this code segment causing an error? If so, what is the error. If this approach will not work for you, what is your specific need?
 

Users who are viewing this thread

Back
Top Bottom