Find a file in a folder

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

Could someone help me for this question?

I try to write code in access to open a file in a folder. The problem is I
can write a code to open the file with using the drive's name
(C:\folder\file.doc). How can I write a code to open a file without using the
drive's name (like: \folder\file.doc)?

If I have a file is in the same folder of the access databse or one level
above the access database folder, how can I write code to get the file?

Thank you for your time!
 
In
Ac said:
Hello,

Could someone help me for this question?

I try to write code in access to open a file in a folder. The problem
is I can write a code to open the file with using the drive's name
(C:\folder\file.doc). How can I write a code to open a file without
using the drive's name (like: \folder\file.doc)?

If I have a file is in the same folder of the access databse or one
level above the access database folder, how can I write code to get
the file?

Thank you for your time!

In Access 2000 and later versions, CurrentProject.Path returns the path
of the folder containing the current database. For example,

Debug.Print Dir(CurrentProject.Path & "\file.doc")

If you want to get the folder one level above that folder, you should be
able to use the directory's ".." entry to refer to it; e.g.,

Debug.Print Dir(CurrentProject.Path & "\..\file.doc")
 
Ac said:
Hello,

Could someone help me for this question?

I try to write code in access to open a file in a folder. The problem is I
can write a code to open the file with using the drive's name
(C:\folder\file.doc). How can I write a code to open a file without using the
drive's name (like: \folder\file.doc)?

If I have a file is in the same folder of the access databse or one level
above the access database folder, how can I write code to get the file?


Your front end database's path (including the drive) is
obtained from:
CurrentProject.Path

The folder above that is:
CurrentProject.Path & "\.."
 
Thanks, It works well!

Ac

Dirk Goldgar said:
In

In Access 2000 and later versions, CurrentProject.Path returns the path
of the folder containing the current database. For example,

Debug.Print Dir(CurrentProject.Path & "\file.doc")

If you want to get the folder one level above that folder, you should be
able to use the directory's ".." entry to refer to it; e.g.,

Debug.Print Dir(CurrentProject.Path & "\..\file.doc")

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Thanks, It works well!

Ac

Marshall Barton said:
Your front end database's path (including the drive) is
obtained from:
CurrentProject.Path

The folder above that is:
CurrentProject.Path & "\.."
 
Back
Top