Timing my Access Form

aym

Registered User.
Local time
Today, 02:15
Joined
Aug 20, 2017
Messages
40
Good day experts
Pls let say i want a user to use Access form for 40Mins. Is there any code that will make my Access Form to have start time and stop time. And i will like the Access Form to close when the time decreases to 00:00:00.

I really need help.
 
A few questions you need to consider or provide an answer to.

What happens if the user is in the middle of editing a record and the time period expires?
Are they allowed to open the same form 5 seconds later, if so what's the point?

What have you tried?
 
Usually when I wanted someone out, I put an OnTimer event on the form with an interval of something like 30 minutes. When the timer fired, I had it put up a modal dialog box to warn the user that his 30 minutes had expired. Then I reloaded the timer for 10 minutes and did it again. Then 5 minutes. Then every minute. But I never actually killed the form because I did not want the user to lose data. Using the modal dialog meant the users HAD to click the OK in order to proceed, but they COULD proceed. It was just that once the time dropped down to once per minute, it got annoying enough that they would finally take the hint.

As Minty points out, you CAN use the OnTimer event to do things, but be careful of doing something that could leave your database in an inconsistent state. That, in my book, is worse than a user overstaying his/her welcome.

If you DO try a timer event, remember that the timer ticks in MILLISECONDS, not seconds, so 30 minutes is 1,800,000 milliseconds. The timer is good for 32-bit (LONG) integers, so you can specify that number. But also remember that drastic control can result in drastic damage.
 
It would probably help us to help you if you gave us some idea, in plain language, as to what you're doing here. Some of the arguments given would be moot, for instance, if you were timing, say, an exam that you are giving using an Access Form, where the abrupt closing of the Form wouldn't really hurt anything.

Linq ;0)>
 
Last edited:
A few questions you need to consider or provide an answer to.

What happens if the user is in the middle of editing a record and the time period expires?
Are they allowed to open the same form 5 seconds later, if so what's the point?

What have you tried?

Thanks for your quick respond Mr. Minty, i have a quiz which i will like to 'time'

Thank you.
 
Usually when I wanted someone out, I put an OnTimer event on the form with an interval of something like 30 minutes. When the timer fired, I had it put up a modal dialog box to warn the user that his 30 minutes had expired. Then I reloaded the timer for 10 minutes and did it again. Then 5 minutes. Then every minute. But I never actually killed the form because I did not want the user to lose data. Using the modal dialog meant the users HAD to click the OK in order to proceed, but they COULD proceed. It was just that once the time dropped down to once per minute, it got annoying enough that they would finally take the hint.

As Minty points out, you CAN use the OnTimer event to do things, but be careful of doing something that could leave your database in an inconsistent state. That, in my book, is worse than a user overstaying his/her welcome.

If you DO try a timer event, remember that the timer ticks in MILLISECONDS, not seconds, so 30 minutes is 1,800,000 milliseconds. The timer is good for 32-bit (LONG) integers, so you can specify that number. But also remember that drastic control can result in drastic damage.


Thanks for your quick respond. i have a quiz which i will like to 'time'

Thank you.

I tried setting the time interval to 60000 which is equal to 10mins using this code below

Private Sub Form_Timer()
Me.TimerInterval=0
DoCmd.Close acForm, Me.Name, acSaveNo
End Sub

It works perfectly but the problem now is that the time is not reducing its just pause. but when the time reach 10min it close the form.
 
Last edited:
rather than close, you could just prevent the exam "answers" being saved if the allowed time has elapsed.

maybe you could even show a countdown timer in the corner somewhere.
 
Thanks for the respond sir. It is a good idea. Can you help me achieve it.
 
The best way to do this is when the timer expires, there is a set of form properties such as form.AllowEdit (and there are other "allow" properties as well.) You can pop up a message box at the expiration of the timer and when the user clicks OK, before you exit the OnTimer routine, set the form's Me.AllowEdit to FALSE. (And any other appropriate "allow" properties.)

If you are using a main form to drive the process and a sub-form in continuous mode to drive the individual questions, you can also set the sub-form's .Allowxxx properties by finding the sub-form control's actual form. If I recall correctly, the general syntax for that is something like Me.sub-form-name.Form - and then you can tack on to that sequence whatever properties of the sub form you wanted to change.

Just to be sure you understand that sequence, "Me" is the form containing the class-module code that you are executing in the OnTimer event. "sub-form-name" is the name of the sub-form control. THAT IS A PLACE-HOLDER! The ".Form" at the end of the sequence is where you reference the form that was associated with the sub-form control, because remember that the sub-form control is a CONTROL, not a FORM. The thing associated with the control is the form you want to modify in that case.

If you are not using a sub-form for your exam, then it gets REALLY complex. If you were not using a form & sub-form setup, you will have to describe it better.
 
I'll give u a rough sample tomorrow, I just left it on the office.
 
as promised.
here is a sample Timed form for your exam.
this is a stand-alone version.
the Questions for the test is on blQuestions.
the Answers of the student are saved in tblStudentAnswer.
you put the Hours/Minutes of the exam duration at tblCountDown.
you need a password to exit the form (currently its arnelgp).

if you need to disable the right-click menu,
you must compile your final db to an accde file.

hold the Shift key while the DB is loading
so you can see the objects and codes in the db.

goodluck with your exam.
 

Attachments

Thanks for the respond sir its been a while, how is the family doing sir my regards. I really miss your posting sir.

I will go through it sir and i will give you feedback sir.
Thanks
 
Last edited:
as promised.
here is a sample Timed form for your exam.
this is a stand-alone version.
the Questions for the test is on blQuestions.
the Answers of the student are saved in tblStudentAnswer.
you put the Hours/Minutes of the exam duration at tblCountDown.
you need a password to exit the form (currently its arnelgp).

if you need to disable the right-click menu,
you must compile your final db to an accde file.

hold the Shift key while the DB is loading
so you can see the objects and codes in the db.

goodluck with your exam.

Thanks for the respond sir its been a while, how is the family doing sir my regards. I really miss your posting
sir.
I will go through it sir and i will give you feedback sir.
Thanks

I have try opening the db but it not opening, instead a message Unrecognized database format was displayed sir. Am using Ms Access 2007
 
Family is ok, tnx. Btw Eid Al Fithir to u and Ur family. I'll send it again after lunch.
 
open the form QuestionaireForm.
 

Attachments

Sorry for the inconveniences sir file still not open.

It worked for me (Access 2010 32-bit) and I thought it was rather neat! :)

Make sure you open it in a trusted location.

I also tried it on my Windows tablet with no keyboard.
It opened but not correctly and I couldn't enter the password to close it.
Had to reboot the tablet to escape.
Thanks arnel ... !:eek:

Arnel:
Actually, it would be good to use this with a tablet.
Would you like me to post with code added to show the on screen keyboard if in tablet mode?
 

Users who are viewing this thread

Back
Top Bottom