Change The Path to files

B

Bruce Rodtnick

I have a database that is on the network drive at work, but on the local
drive at home.
Example:

Office database directory
f:\workfiles\

Home database directory
c:\homefiles\

The Access database is in a subdirectory of these directories.
Examples:
f:\workfiles\Access\Mydatabase.mdb
or
c:\homefiles\Access\Mydatabase.mdb

I want to get a list of the files in the "root" directory. I'll be putting
the the results in a list box using this code:

list box, with these properties:
Name lstFileList
Row Source Type Value List
On Load property of the form to:
Private Sub Form_Load()
Call ListFiles("<ThisComputerfiles>, , Me.lstFileList)
End Sub

How do I get Access to look at this system's drive and the directory UNDER
it's own directory depending on which system I'm working on?

Bruce
 
D

Daniel

Probably the easiest way would be to test for the existance of the f: drive
and if it doesn't exists then use c:\

Public Function FolderExists(ByVal PathName As String) As Boolean
Dim nAttr As Long
' Grab the attributes, test valid values for folder bit.
On Error GoTo NoFolder
nAttr = GetAttr(PathName)
If (nAttr And vbDirectory) = vbDirectory Then
FolderExists = True
End If
NoFolder:
End Function

Then simply a test for your f:\ by doing

FolderExists("f:\")

This would mean you would have to manipulate the filepaths on the fly using
vba by changing the first character based on the existance of the f:' folder
or not.

Hope this helps,

Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top