473,386 Members | 2,129 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,386 software developers and data experts.

How to code a macro timer close the access database at 5:00pm every day

i have an access database that needs a macro timer to close down the database automatically.run every night. I don't know how to code this macro timer in VBA. Please help!
Yolly
Nov 1 '10 #1
2 9521
jimatqsi
1,271 Expert 1GB
Yolly,
When the Access database is opened, automatically open a form to be the timer form. You might want to make it invisible, or make it very small and place it in a corner of the screen where the user can see it and be reminded that the thing will shut down at 5:00.

There are two Event properties you will set. In Timer Interval, put a number (N * 60000), where N is the frequency in minutes you want to check to see if it is 5:00 or later. If you want to check every 30 minutes, you will put a value of 1,800,000.

In the OnTimer event of the Form, place the following code:

Expand|Select|Wrap|Line Numbers
  1. if hour(now()) = 17 then
  2.  DoCmd.Quit
  3. endif
  4.  
You might want to issue a warning message in case somebody is working in the program. If you want to quit exactly at 5:00, then you could subtract the time between 5:00 and the current time, and use vba code to change the timer interval to the number of milliseconds until 5:00. The next time the timer fires, it will be 5:00.

Jim
Nov 1 '10 #2
jimatqsi
1,271 Expert 1GB
I believe you might have to check for the hour = 5 instead of 17, depends on the format the system returns the time.

Jim
Nov 1 '10 #3

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

Similar topics

0
by: jack daniels via .NET 247 | last post by:
Hi! Perhaps you know of a better way here. I have an Access database, actually a single table. Now, at the click of a button on a C# Form, each and every single cell associated with the primary...
4
by: mvivar | last post by:
Hi everybody: This will be not easy to explain as my mother language is not english, so my apologies in advance if it sounds confusing. We have a database access 97 wich controls time of...
0
by: marko | last post by:
Hi all! I'm trying to make a access database for my fathers shop and I'm pretty stuck so if anyone could help me that would mean a great deal for me! I would like to make a database in wich the...
4
by: authorking | last post by:
I use the following code to insert a data record in to a datatable of an access database.But every time I execute the command, there will rise an exception and the insert operation can't be...
1
by: Roy Gourgi | last post by:
Hi, I am using VS.NET 2003 and I have made a connection to a MS Access database using the Server Explorer. Is this connection permanent, meaning that it will be there every time I reopen my...
3
by: route_coder | last post by:
I am using access database to create a crystal report in VB.NET Everything works fine when I run on my machine. But when I am deploying it other windows machines. It is asking for database server...
7
by: Allison | last post by:
Hi -- we are a small manufacturing looking for a multi-user database to take customer orders (nothing too complicated, with 3 users total). We think we should be using Access, but are wondering...
12
by: =?Utf-8?B?Smlt?= | last post by:
I have code that reads and parses a text file using a schema.ini file. Works great. When I see the dataGrid it's exactly what I want. Dim CString As String = _...
1
by: blazinjoe1 | last post by:
Hey guys, I have tryed something new code with updating an access database but the error Syntax error in UPDATE statement occurs every time i try to update. Can some please help me figure...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.