How to open a text file using a relative path?

W

winner

Hi, I have a config.txt file in a folder that contains a .mdb file. I want to write code in the .mdb file to open the config.txt file. How do I supply a relative path for Open file_path for Input as #1? Thanks
 
S

Scott

Try this:

Dim theFile As String
Dim slashPos As Long

theFile = currentdb.Name 'get the db name and full path
slashPos = InStrRev(theFile, "\")
theFile = Left(theFile, slashPos)
& "config.txt" 'append the name of the config file
'then open theFile however you already are doing it
-----Original Message-----
Hi, I have a config.txt file in a folder that contains
a .mdb file. I want to write code in the .mdb file to
open the config.txt file. How do I supply a relative path
for Open file_path for Input as #1? Thanks
 

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