Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Mar 2006
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Path with the last day (Access 2000)

    I am opening sucesfully a database with the following function
    Public Const CnstSurvey = "C:BEsurvey.mdb"
    Public Function OpenSurvey()
    Dim appAccess As Access.Application
    Set appAccess = CreateObject("Access.Application")
    appAccess.OpenCurrentDatabase CnstSurvey
    End Function
    I want however to have databases ending with different days, for example
    Survey20060327
    or
    Survey20060326
    and to open that database which has the latest date. Is it possible ?

  2. Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Path with the last day (Access 2000)

    Try this:
    <code>
    ' Path including backslash
    Public Const strPath = "C:BE"

    Public Sub OpenSurvey()
    Dim appAccess As Access.Application
    Dim strFile As String
    Dim strLatest As String

    strFile = Dir(strPath & "Survey*.mdb")
    ' Loop through the files in the folder
    Do While Not strFile = ""
    ' See if we have a later file
    If strFile > strLatest Then
    strLatest = strFile
    End If
    ' And on to the next
    strFile = Dir
    Loop

    ' Did we find a file?
    If Not strLatest = "" Then
    ' If so, open it
    Set appAccess = CreateObject("Access.Application")
    appAccess.OpenCurrentDatabase(strPath & strLatest)
    End If
    End Sub</code>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •