473,385 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

I wish a message to display at a certain time in access

I am trying to display a message at 17:30 to remind users to close their access database. Can this be done using VBA attached to a from and if so how?
Jun 18 '10 #1

✓ answered by TheSmileyCoder

You can make a hidden form, that is opened at startup, and then create a timer event on that. Timer events are run every X seconds, where X is a value you can specify(in miliseconds). You can then simply check what the time is using time(). An example of the code is shown below. Remember in the form to set the timerinterval to something like 30000 I.e. every 30 secs
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Timer()
  2.     If Time() > #17:30:00 PM# Then
  3.         MsgBox "Please remember to close your database!"
  4.         DoCmd.Close
  5.     End If
  6.  
  7. End Sub
Welcome to Bytes

8 4316
TheSmileyCoder
2,322 Expert Mod 2GB
You can make a hidden form, that is opened at startup, and then create a timer event on that. Timer events are run every X seconds, where X is a value you can specify(in miliseconds). You can then simply check what the time is using time(). An example of the code is shown below. Remember in the form to set the timerinterval to something like 30000 I.e. every 30 secs
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Timer()
  2.     If Time() > #17:30:00 PM# Then
  3.         MsgBox "Please remember to close your database!"
  4.         DoCmd.Close
  5.     End If
  6.  
  7. End Sub
Welcome to Bytes
Jun 18 '10 #2
Thanks Smiley. Made me smile
Jun 18 '10 #3
NeoPa
32,556 Expert Mod 16PB
Nice answer Smiley. An alternative would be to reset the timer value when done, to something like 900,000 to ensure another reminder is sent if they're not out within 15 minutes. The form will be closed when the database is closed.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Timer()
  2.     If Time() > #17:30:00# Then
  3.         Call MsgBox("Please remember to close your database before you leave!")
  4.         'Call DoCmd.Close
  5.         Me.TimerInterval = 900000
  6.     End If
  7. End Sub
Jun 18 '10 #4
@NeoPa
Thanks NeoPa. Figured that bit. I attached the timer event to the switchboard with a timer interval of 600000, so every 10 minutes she will get the reminder.
Jun 18 '10 #5
NeoPa
32,556 Expert Mod 16PB
Cool. Sounds like you already have someone in mind that needs this ;)

Just a caveat. Remember when using the TimerEvent() to bear it in mind if ever you're debugging anything. It can make life quite complicated at times.
Jun 18 '10 #6
It was fun when I set the time to 5 minutes ago and the timer interval to 1000 milliseconds so that I could see the result straight away. I couldn't close the message box fast enough to get back to design view. :>(
Jun 18 '10 #7
NeoPa
32,556 Expert Mod 16PB
:D

Did I mention you may have problems debugging with a timer event enabled!
Jun 18 '10 #8
FishVal
2,653 Expert 2GB
Just a suggestion:


Since time difference is available when code runs first time, TimerInterval could be calculated to fire Form_Timer event exactly at expected time. This, however, is not an option in a case when system time is expected to be changed while TimerInterval is counted down. By the way, Form_Timer event handler may not run if there is some form opened as modal. If so, then programming Windows system timer via WinAPI could be an option.

Regards,
Fish
Jun 21 '10 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Matt | last post by:
Are there any settings to make a page invisible to the user until certain time? For example, I want mypage.html is invisible to the user until 12:00am. But mypage.html is already in the IIS server....
4
by: MLH | last post by:
Is it possible for me to open, read and display a specific eMail message from within an Access database? Perhaps I have received an eMail from a customer in the customers table that I wish to save...
4
by: CH | last post by:
Hi, I recently encountered a problem while trying to create a report grouped by certain time frames. However, Access only allows grouping in Minutes or Hours. For example, the first time frame is...
1
by: abhi.10dulkar | last post by:
Hi guys, This might be simplest thing, but I am newbie to databases. I need to find out only rows modified within certain time period from a database. As I undertand a way out could be adding...
4
by: eladla | last post by:
I have a windows service that I want to carry out an action on a certain day of the week at a certain time and if the time is missed for some reason, I want it to be carried out as soon as the...
1
by: brchudson | last post by:
We use Access as a task scheduler. Right now I have it set up so that task must be scheduled tomorrow or later, however, I want to set it up so I can also prevent scheduling on a certain date after...
3
by: Tamer Ibrahim | last post by:
How can I get just a certain time from the user ? Any idea how to do this ...
2
by: CSmith | last post by:
I have a database that holds all the tables for multiple other databases that the tables are linked to. I need to access the database everyday at a certain time and can't seem to get the users to...
4
by: joaotsetsemoita | last post by:
hello everyone. Im trying to time out a loot after a certain time. Probably 5 to 10 minutes. I have the following function Private Sub processFileCreation(ByVal source As Object, ByVal e As...
2
by: Dale | last post by:
Access 2003 I have an access database used for scoring a high school sporting event. Data is entered as scores are turned in from the different events throughout the day. I would like to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.