Dos Command

  • Thread starter Thread starter tvae
  • Start date Start date
T

tvae

Guest
I am trying to figure out how can I do this.

I can have a bat file and call that bat file to run a command.

Command: c:\Dir *.mdb /s/b > c:\database.txt

Now i need it to be more flexible that the user can enter which drive they want to search so I am not sure how can i make it more flexible that they can enter the drive letter in a form. So I can have:

[enter drive] Dir *.mdb.........

Can someone let me know what should i do.

Thanks
 
What is your batch file doing? You should be able to do what you want with VBA instead of DOS.
 
Looks like it's getting a list of all the mdb's and writing their names to the .txt.

ken
 
tvae - Does this work within access?

???
ken
 
Yes it works in access by calling a bat file.

ghudson, do you know the syntax to call this in VBA?
 
Dim RetVal
RetVal = Shell("C:\WINDOWS\CALC.EXE", 1)

Would this work?
ken
 
The below function will search for mdb files in a specific directory. It will write the results to a table named tTempFiles which has three fields named [TempFilePath], [TempFileName] & [TempFileDate].
Code:
Public Function ListFiles()
On Error GoTo Err_ListFiles
    
    Dim rs As Recordset
    Dim sFile As Variant
    
    Const sPath = "C:\Temp\"
    
    CurrentDb.Execute "Delete tTempFiles.* from tTempFiles;"
    
    Set rs = CurrentDb.OpenRecordset("tTempFiles")
    
    sFile = Dir(sPath & "*.mdb")
    'sFile = Dir(sPath & "*.*")
    Do Until sFile = ""
        rs.AddNew
        rs!TempFilePath = sPath
        rs!TempFileName = sFile
        rs!TempFileDate = FileDateTime(sPath & sFile)
        rs.Update
        sFile = Dir
    Loop
    
    rs.Close
    Set rs = Nothing
    
Exit_ListFiles:
    Exit Function
    
Err_ListFiles:
    MsgBox Err.Number & " " & Err.Description
    Resume Exit_ListFiles
    
End Function
 
ghudson,

that's about what i got but i am trying to make it that they will just be able to select a drive and it will search all the subfolders and include the mdbs under the subfolder. That is why i got the bat file to list all mdbs under a certain drive or folder.

any ideas?

Thanks
 

Users who are viewing this thread

Back
Top Bottom