Results 1 to 8 of 8
  1. #1
    Two Gun is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    22

    Last Update to Linked Spreadsheet

    I export data from a system to an excel spreadsheet, which is linked to my database. When I run reports in Access, is there any way to identify when the linked table was last updated? This would be helpful to users if I could add a text box that shows "Data current as of" some date. Thanks.

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    I use the DateValue function in VBA to check if files that I am importing from Excel have the current date.

    For your case, you can create a function - like this:

    Code:
     
    Function Get_File_Date()
    Dim FilePath, FileName As String
    Dim FileDate As Date
     
    FilePath = "C:\DirectoryName\"
    FileName = "FileName.xlsx"
     
    Get_File_Date = DateValue(FileDateTime(FilePath & FileName))
     
    End Function
    and then in your query design view, add a field like this:
    Code:
     
    FileDate: Get_File_Date()
    When you run your query, it will put the Modified Date of your spreadsheet in that field of your query.

    Let me know if this helps!

  3. #3
    Two Gun is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    22
    Works like a charm! Thanks much.

  4. #4
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Happy to help.

    One problem I've noticed with this. If the table is Large - then the query will be slow - because it is hitting that function for each row of data.
    Whenever I've used this trick in a query - there hasn't been another way and the reports that use these queries run early in the morning before I get to work anyway - so I don't notice the lag!!

  5. #5
    Two Gun is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    22
    Robeen - This has worked perfectly since you shared your solution ... thanks again. However, the date is displayed as 1/9/12. Any chance VBA would allow me to format a long date ... Monday, January 9, 2012? I've tried everything I can think of, with no luck.

  6. #6
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    You can use the Format() function in your Query to return the date in the format you mentioned.

    Instead of:
    Code:
     FileDate: Get_File_Date()
    Try:
    Code:
     FileDate: Format(Get_File_Date(), "dddd, mmm d yyyy")

  7. #7
    Two Gun is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    22
    Again ... works perfectly. Thanks much!

  8. #8
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Glad I could help!

    Happy Trails!

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

Similar Threads

  1. Replies: 7
    Last Post: 08-18-2011, 02:18 PM
  2. Update different records in a Linked Table
    By Lorlai in forum Import/Export Data
    Replies: 3
    Last Post: 06-14-2011, 02:01 PM
  3. Replies: 1
    Last Post: 01-22-2011, 12:23 PM
  4. Update statement with linked table join
    By Guigui in forum Queries
    Replies: 6
    Last Post: 09-17-2010, 04:47 AM
  5. auto update of two linked tables
    By colenzo in forum Access
    Replies: 4
    Last Post: 07-20-2009, 09:08 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