Results 1 to 4 of 4
  1. #1
    darwish is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2014
    Posts
    26

    do a function at specific time

    hello

    I have a function that takes a backup of a certain file



    but i want this function to run every day at 7 p.m.

    how can i do that using VBA?

    thanks in advance

  2. #2
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    If you are only going to backup a file, why not just use the windows scheduler.

    http://support.microsoft.com/kb/308569

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    but if you want to do it in a form....
    the form has the property TIMER INTERVAL...set it to 1000 (its in milliseconds, so 1000 = 1 second) 0 = off
    every second that goes by, the property ON TIMER gets called. Your code would go here to trigger the copy.
    Code:
    Private Sub Form_Timer()
    if TIME() = #7:00 pm# then  CopyFiles

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Instead of VBA I would use VB Script and the Task Scheduler.

    Here is some code you can save as VBS that will copy files and paste them in a destination folder
    Code:
    Dim sourceFile
    Dim destinationFile
    Dim strDesFilName
    Dim strNow
    Dim aFSO
    strNow = Year(Date) & "_" & Month(Date) & "_" & Day(Date) & "_" & Hour(Now) & Minute(Now) & "_" & Second(Now)
    strDesFilName = "Inv_Copy_" & strNow & ".accdb"
    destinationFile = "C:\Inventory_Backup\" & strDesFilName
    sourceFile = "\\SERVERNAME\Folder\FileName.extension"
    Set aFSO = CreateObject("Scripting.FileSystemObject")
    aFSO.CopyFile sourceFile, destinationFile
    If you want an Access DB to manage all of the work, you can use task scheduler to open the Access file. My preference is to use VB Script to open Access files but this poster found a way to open Access directly with Task Scheduler
    https://www.accessforums.net/access/...pro-42227.html

Please reply to this thread with any new information or opinions.

Similar Threads

  1. a function in specific field
    By Rasha in forum Access
    Replies: 1
    Last Post: 04-26-2014, 05:48 AM
  2. Replies: 7
    Last Post: 02-20-2014, 02:34 PM
  3. Get records after specific date and time
    By rooster in forum Queries
    Replies: 6
    Last Post: 09-15-2013, 11:32 PM
  4. Replies: 1
    Last Post: 08-14-2012, 03:22 AM
  5. Replies: 15
    Last Post: 02-16-2010, 10:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums