Problem with CurDir

C

Chaplain Doug

Access 2002. I am having a problem with the results of
the CurDir (current directory) function. The access
database I am running is in:

C:\Documents and Settings\The Pruiett Family\My
Documents\Databases\Good News\Golf Event

However, the CurDir function returns:

C:\Documents and Settings\The Pruiett Family\My Documents

Why would this occur?

The problem cropped up because the Dir function was
indicating that a file did not exist when it indeed exists
in the same folder that the database running exists in.
When I checked CurDir I them knew why, because the Dir
function was looking in the wrong place. I though CurDir
would default to the directory in which the database
resides. Thanks for the help.
 
D

Douglas J. Steele

CurDir has nothing to do with where the MDB file is located. What its value
is depends on how you opened the application. I think it'll be the same as
whatever's in the "Start In" folder if you use a shortcut. If you
double-click on a file in Explorer, though, it's anyone's guess what it'll
be.

To determine where the current MDB file is located, you can use
CurrentApplication.Path

Alternatively, you can use

Left$(CurrentDb.Name, Len(CurrentDb.Name) - Len(Dir$(CurrentDb.Name)))
 
C

Chaplain Doug

Dear Doug,

You and others have been of such great help to me on
numerous occasions. Thank you. Another question. I am
currently serving as a missionary chaplain in a penal
institution. I have also served as a pastor. Prior to
going into the ministry in late 1996 I served 17 years as
a scientific programming specialist, hence the reason a
chaplain is programming. It appears that I am going to be
doing a lot more Access database design and programming
for my organization. I have never had a course in VBA or
in Access programming. I have been living off of the
Newsgroups! Can you give me some direction as to how or
where I may get some education in VBA and Access
programming? Thanks for any help or direction you can
give. God bless.
 
C

Chaplain Doug

I get an error using

CurrentApplication.Path

Is there a library I need to add to references to get this
method?
 
S

Scott McDaniel

As you've found, these newsgroups are invaluable for help. I swear by the
Access Developer's Handbook (3 volume set) ... every time I open it I seem
to learn something new.
 
D

Douglas J. Steele

Oops! Thanks for bailing me out, Scott.

I do virtually all my work in Access 97, so I don't always remember the new
syntax correctly...
 
M

M.L. Sco Scofield

For a starter book, Access VBA Step by Step from MSPress is good.

My favorite is Beginning Access VBA from Wrox. (A lot of my VBA students
also like it.)

As someone else mentioned, the Access Developer's Handbook from Sybex has a
lot of good code in it. Only problem is that it's not a tutorial like the
other two. Myself, I have all of them. (And some others. :)

--

Sco

M.L. "Sco" Scofield, MCSD, MCP, MSS, Access MVP, A+
Useful Metric Conversion #16 of 19: 2 monograms = 1 diagram
Miscellaneous Access and VB "stuff" at www.ScoBiz.com
 

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