Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2007
    Posts
    2

    Unanswered: MSAccess VB code which appends date to filename?

    Anyone have the code that MSAccess uses when you run the back-up database command which appends the date to the db's filename?
    Appreciated if u do. Thanx.
    Last edited by MalaT; 09-11-07 at 07:22. Reason: to make request clearer.

  2. #2
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5

    good code snippet to get file info

    Public Function GetFileInfo(FileName As String, Optional fReturn As String) As String
    On Error GoTo err_fInfo

    Dim myFSO, myFileObject

    Dim lngAttributes As Long 'Attribute Values, explanation below
    Dim datCreated As Date 'Date and time the file was created.
    Dim datLastAccessed As Date 'Date and time the file was last accessed.
    Dim datLastModified As Date 'Date and time the file was last modified.
    Dim strDrive As String 'Drive letter of the drive where the file resides.
    Dim strName As String 'Sets or returns the name of the file.
    Dim strPath As String 'The path of the file, including drive letter.
    Dim strSize As String 'The size, in bytes, of the file.


    Set myFSO = CreateObject("Scripting.FileSystemObject")
    Set myFileObject = myFSO.GetFile(FileName)

    If fReturn = "" Then
    With myFileObject
    lngAttributes = .Attributes
    datCreated = .DateCreated
    datLastAccessed = .dateLastAccessed
    datLastModified = .dateLastModified
    strDrive = .Drive
    strName = .Name
    strPath = .path
    strSize = .Size
    End With
    ' return all file info as string
    GetFileInfo = "File Information for file:" & vbCrLf & vbCrLf & _
    "Filename: " & strName & vbCrLf & _
    "Attributes: " & lngAttributes & vbCrLf & _
    "Date Created: " & datCreated & vbCrLf & _
    "Date last Accessed: " & datLastAccessed & vbCrLf & _
    "Date Last Modified: " & datLastModified & vbCrLf & _
    "Drive: " & strDrive & vbCrLf & _
    "Path: " & strPath & vbCrLf & _
    "Size: " & strSize & " Bytes"
    Else
    Dim vReturn As Variant
    Select Case fReturn
    Case "DateCreated"
    vReturn = myFileObject.DateCreated
    Case "DateLastMod"
    vReturn = myFileObject.dateLastModified
    Case "DateLastAccessed"
    vReturn = myFileObject.dateLastAccessed
    Case "Size"
    vReturn = myFileObject.Size & " Bytes"
    Case Else
    vReturn = myFileObject.Name
    End Select
    GetFileInfo = vReturn
    End If

    Exit_err:
    Set myFileObject = Nothing
    Set myFSO = Nothing
    Exit Function
    err_fInfo:
    GetFileInfo = Err.Description
    Resume Exit_err

    End Function ' GetFileInfo
    Dale Houston, TX

  3. #3
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5
    a great link for using vba filesystem object

    http://www.techbookreport.com/tutorials/fso1.html
    Dale Houston, TX

Posting Permissions

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