Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 26th, 2007, 02:31 PM
Authorized User
 
Join Date: Oct 2007
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default Closing MS Access at a set time

I am trying to find a way to close MS Access at a set time. I currently use a hidden form to close access after it has been inactive for a set period of time. I need the ability to close it at a set time because I have not been very successful with making backups, it will not back up my database files because they are open.

Tony

 
Old October 26th, 2007, 05:08 PM
Friend of Wrox
 
Join Date: Feb 2007
Posts: 163
Thanks: 0
Thanked 2 Times in 2 Posts
Default

You have to have a form open and running that has the timer property set.

On the Event tab of the form properties:
1) Set timer interval. Note: 1 second would be a value of 1000
2) Create an On Timer event procedure for the form. That procedure can check the time and exit the database at that time. Note: If the DB is opened on other machines you still may have the same problem even if you close it on your machine.

 
Old October 29th, 2007, 06:28 AM
Authorized User
 
Join Date: Oct 2007
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply allenm

What code would I use to check the current time and compare it to the current time using VBA

 
Old October 29th, 2007, 07:23 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hi,

If you do this on the On Timer event:

First set the Form's Timer Interval property to some value, like 10000 to check the time every 10 seconds, or longer, then on the On Timer event, do this (adding your own time, of course):

Dim dtTime As Date

dtTime = TimeValue(Time)

If dtTime >= #8:20:00 AM# Then
    Application.Quit
End If


This is going to shut the app down at a specific time. It just shuts it down, so make sure you want to do this.

Did that help?


mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old October 29th, 2007, 07:25 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

That was in the Access 2003 VBA Programmer's Reference, btw, Chapter 10 on Event Property and Procedure Examples.


mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old October 29th, 2007, 12:15 PM
Authorized User
 
Join Date: Oct 2007
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for all the help :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert UNIX Time to MS Access Corey Linux 4 April 7th, 2009 11:52 AM
MS ACCESS 2003 FRONTEND AND MS SQL SERVER 2005 DB mohankumar0709 SQL Server 2005 3 March 23rd, 2007 12:48 AM
Time triggered macro in MS Access d-fxt Access 6 December 19th, 2006 06:39 PM
Convert UNIX Time to MS Access Corey Access 1 January 23rd, 2006 12:32 AM
Syntax to query Date/Time in MS ACCESS chiuyianl Access 4 March 31st, 2005 09:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.