Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Check Files (Access 2000)

    I am checking the files with the ending mdb with the following code:


    Dim CheckFile As String
    Dim strList As String
    CheckFile = Dir(strPath & "/*.mdb")
    Do Until CheckFile = ""
    strList = strList & vbCrLf & CheckFile
    CheckFile = Dir
    Loop
    Me.txtDatabaseList = Mid$(strList, 3)
    End Sub
    Private Sub Form_Load()
    Me.txtFolder = "C:BE"
    GetDBList Me.txtFolder
    ' Move to new record
    RunCommand acCmdRecordsGoToNew
    Me.txtFolder = "C:BEstore"
    GetDBList Me.txtFolder
    End Sub



    How can i write to check the files on the desktop? And also,How can i check the zipped files?
    The zipped fiels should have some other ending beside mdb.

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

    Re: Check Files (Access 2000)

    You can get the path to the user's desktop as follows:

    Function GetDesktop() As String
    Dim WSHShell As Object
    Set WSHShell = CreateObject("WScript.Shell")
    GetDesktop = WSHShell.SpecialFolders("Desktop")
    Set WSHShell = Nothing
    End Function

    You can then use

    Me.txtFolder = GetDesktop
    GetDBList Me.txtFolder

    As you might guess, zipped files have the extension .zip, so you can either create a new procedure GetZipList, or create a more general procedure that takes the extension as argument.

  3. #3
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Check Files (Access 2000)

    Than you very much for your reply. It works fine.I only cannot combine both the mdb and the zipped files.
    I get either mdb files or the list of the zipped files,as you can see from ther attachment.
    How can i combine them in such a way, as to enumerate both mdb and zipped mdbs?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Check Files (Access 2000)

    Change the GetDBList and GetDBZList procedures to functions:

    Private Function GetDBList(ByRef strPath As String) As String
    Dim CheckFile As String
    Dim strList As String
    CheckFile = Dir(strPath & "/*.mdb")
    Do Until CheckFile = ""
    strList = strList & vbCrLf & CheckFile
    CheckFile = Dir
    Loop
    GetDBList = Mid$(strList, 3)
    End Function

    Private Function GetDBZList(ByRef strPath As String) As String
    Dim CheckFile As String
    Dim strList As String
    CheckFile = Dir(strPath & "/*.Zip")
    Do Until CheckFile = ""
    strList = strList & vbCrLf & CheckFile
    CheckFile = Dir
    Loop
    GetDBZList = Mid$(strList, 3)
    End Function

    Call them like this in Form_Load:

    Me.txtDatabaseList = GetDBList(Me.txtFolder) & vbCrLf & GetDBZList(Me.txtFolder)

Posting Permissions

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