Results 1 to 5 of 5
  1. #1
    nhylan is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    12

    Import Excel file based on a date and time in file name

    Hi all,



    I'm trying to import to files into a database and this would need to happen on a daily basis. The files naming scheme works like this:

    [clientname]_a date(mmddyyyy format)_"00:00 time"

    Basically we get this file multiple times per day and what I want to know is this. Is there a way that I can always have it import the file which is current day and lists 2:30pm as the time, and another file which will always be the one from 9:00pm the previous business day.

    for instance is we are talking about today and yesterday the two files will be named like this:

    "name"_04162013_1430.xls (today's file)

    and

    "name"_04152013_2100.xls (prior business day's file)

    Unfortunately I have zero VBA experience and most of my experience in Access has been using Macros and just the ribbon import tools so your patience and expertise is greatly appreciated. Let me know if I can provide any addition info.

    Thanks,
    NH

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    You can use concatenation to construct the file name with date value:

    "name" & Format(Date(), "_mmddyyyy_1430.xl\s")

    "name" & Format(Date()-1, "_mmddyyyy_2100.xl\s")

    What is the "name" part - a literal string that is constant?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    nhylan is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    12
    Hey, thanks for responding. Yes the name part is a constant. Can you use the concatenate functionality within the regular "link an excel file" functionality or do you have to use VBA?

  4. #4
    nhylan is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    12
    Another question for you,
    if I use "name" & Format(Date()-1, "_mmddyyyy_2100.xl\s") like you describe above, what happens if I try to run this on a Monday and it can't find a file with Sunday's date? will it default to the most recent past day?

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    No way for variable concatenation with import/link wizard.

    VBA should be able to set link to Excel. Try DoCmd.TransferSpreadsheet method.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Import Excel File using a Macro
    By smakkiee in forum Access
    Replies: 6
    Last Post: 04-28-2014, 08:45 AM
  2. Import Data from an Web Based .txt File
    By Subwind in forum Import/Export Data
    Replies: 7
    Last Post: 07-25-2012, 05:02 AM
  3. Import Specific cells from Excel based on selected file.
    By Only4Access in forum Programming
    Replies: 5
    Last Post: 02-29-2012, 02:32 AM
  4. Excel Import - File with row spaces
    By Jackfam58 in forum Import/Export Data
    Replies: 1
    Last Post: 04-13-2011, 07:35 PM
  5. Import Excel File Using Macro?
    By oregoncrete in forum Import/Export Data
    Replies: 0
    Last Post: 04-05-2011, 12:26 PM

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