Quit access if inactive

gaj104

Well-known Member
Joined
Nov 9, 2002
Messages
864
Hi,

Is it possible to have a code running in the background which will quit access if the specific database is not being used.

I have made an exclusive database and if people forget to quit out then it will automatically exit after a period of x mins of inactivity.

Many thanks
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

SydneyGeek

MrExcel MVP
Joined
Aug 5, 2003
Messages
12,251
Graeme, this can be done with a form that is ALWAYS open -- such as a menu form, or a hidden form that opens when the database launches.

Let's say you have a hidden form called frmScan, with an unbound textbox called txtTime.

In the form's Load event, you need the one-liner
txtTime=0

In the OnTime event you need
txtTime = txtTime + 1
If txtTime >=20 Then
DoCmd.Quit
End If
(this will quit after 20 minutes -- change to suit)

In the TimerInterval property put 60000 (that's 60 seconds -- TimerInterval works in milliseconds).

OK, at the moment the DB will spontaneously shut after 20 minutes. What you need in the BeforeUpdate event of EACH data entry form is this:
Forms!frmScan!txtTime = 0
This resets txtTime every time you save a record. So, if you keep using the DB it will stay open. When you go away for lunch or a meeting, it will close.

Denis
 

VicRauch

Well-known Member
Joined
Mar 23, 2006
Messages
2,032
I just wanted to ask the obvious question. Why have a database that only one person can use at a time? Why not let multiple users on at the same time?
 

gaj104

Well-known Member
Joined
Nov 9, 2002
Messages
864
I just wanted to ask the obvious question. Why have a database that only one person can use at a time? Why not let multiple users on at the same time?

Hi Vic,

The database queries another database which the user determines the date, and the resultant table is used to create a variety of reports and queries.

It therefore is impractible for multiple users to change the date if another user is using a different date as the generated dynamic table contains around 70,000 rows.

Hi, SyndneyGeek

Thanks for the reply, I like the logic behind your idea. The only query I had on it was that the user will not be updating records per say, only running queries and pressing buttons (as everything is automated). Will the same principle work?

Many thanks
 

sam slade

New Member
Joined
Sep 14, 2006
Messages
22
gaj104,

i think what sydneygeek is getting at is the hidden form routine will reset itself WHEN any action is performed, whether a query is run or switch between controls. not just the saving of records.

Hope this helps.
 

SydneyGeek

MrExcel MVP
Joined
Aug 5, 2003
Messages
12,251
Yep, the idea will work for any activity, as long as you trap it.

I had it set to work on saved records, but you could attach the code to the Click event of any button, for instance.

Denis
 

Forum statistics

Threads
1,141,681
Messages
5,707,792
Members
421,527
Latest member
Tamiwsw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top