Results 1 to 4 of 4
  1. #1
    540MahoneyJF is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2021
    Posts
    5

    Adding time to a line of code in VBA

    Good day,



    I am trying to complete an automatic backup of a database by clicking on a button. Wondering if someone to show me how to add the time to the backup name. Code is as follows:

    Target = "G:\FILE LOCATION\STAFFING DATABASE\DATABASE BACKUPS\STAFFING DATABASE-"
    Target = Target & Format(Date, "DD-MMMM-YYYY") & ".accdb"

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    i use:

    vName =CurrentDb.Name & "_Backup_" & format(now,"yymmdd-hhnn") & ".accdb"

  3. #3
    540MahoneyJF is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2021
    Posts
    5
    so its safe to assume that the following would work?

    Target = "G:\FILE LOCATION\STAFFING DATABASE\DATABASE BACKUPS\STAFFING DATABASE-"
    Target = CurrentDb.Name & "_Backup_" & format(now,"yymmdd-hhnn") & ".accdb"

  4. #4
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    No not really, try

    Application.CurrentProject.Path

    for the current DB path, remember to add a "" if you are adding a filename.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

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

Similar Threads

  1. Replies: 1
    Last Post: 10-19-2018, 04:27 PM
  2. Code is adding an extra record every time
    By mooreb55020 in forum Access
    Replies: 18
    Last Post: 10-09-2018, 07:41 AM
  3. Replies: 1
    Last Post: 11-11-2014, 03:54 PM
  4. How to do line by line compare of VB code?
    By Buakaw in forum Access
    Replies: 2
    Last Post: 02-14-2011, 11:46 PM
  5. Replies: 5
    Last Post: 12-06-2010, 10:15 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