Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

App.Path 3

Status
Not open for further replies.

liamcorkhill

Programmer
Jul 3, 2001
18
0
0
GB
Is there any MS Access VBA equivalent of the VB App.Path statement?
App.Path returns the location of the application. I would like a statement which returns the location of my MDB file.

Regards

Liam Corkhill
 
curdir() will return the current directory. (Don't feel bad, it took me a long time to find this function too.)

B-)
 
Little Problem :-(

CurDir() doesnt seem to return the correct path. My database is in K:\SHIPSDB and it returns D:\MSOFFICE\DBASE.

Any suggestions?
 
try this

Dim strMdb As String, strDir As String
Dim intAt As Integer
For intAt = 1 To Len(CurrentDb.Name)
If Mid(CurrentDb.Name, intAt, 1) = "\" Then
strMdb = Mid(CurrentDb.Name, intAt + 1)
strDir = Left(CurrentDb.Name, intAt)
Exit For
End If
Next intAt
MsgBox "MDB Name is: " & strMdb
MsgBox "Directory is: " & strDir
MsgBox "Current Directory is: " & CurDir()

PaulF
 
Only in Access 2000
you can use this NEW command
Application.CurrentProject.Path

There is a whole slew of new Applicaiton. parameters at your disposal

I love app.path in VB too.

DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
All Fixed. CurrentDB.Name in PaulF's solution worked, and I modified my code to use the whole DB name. Many thanks to all who responded.

Regards

Liam Corkhill

(Still using Access 97 :-( )
 
actually the procedure I provided you yesterday only does the trick when you don't have subfolders, it checks from left to right..... what I should have provided to you was this one, which checks from the right to left.

intAt = Len(CurrentDb.Name)
Do
If Mid(CurrentDb.Name, intAt, 1) = "\" Then
strMdb = Mid(CurrentDb.Name, intAt + 1)
strDir = Left(CurrentDb.Name, intAt)
Exit Do
End If
intAt = intAt - 1
Loop

Sorry about that

PaulF
 
Where would I put this code to get this to work?

I am guessing this code will relay the path to where the database is located, is this true?

What would be the function of such code? Is it useful for something I am not aware of, and how could I utilize it in my DB?

Thanks~

This could be very useful to me if it would (in a textbox or label) show what the path of the current database location is . . . can this do that?
 
Yes this code does return the path to the current database along with the name of the MDB. I've used this in the past to refresh linked tables in other MDBs that I keep in the same folder (i.e. FrontEnd and BackEnd MDBs) or to check for other related files that I would keep in the same folder. Where you call it from depends on how you want to use it.

PaulF
 
I just want it in a textbox . . .

just something that will display the name of the currently installed folder.

where would I put this code to make that happen?

Thanks . . .
 
Are you using Access 2000?

this returns the path

Application.CurrentProject.Path

am I missing something here????

DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Yes, your missing the fact that I am an idiot . . .

I have a textbox, ready to input this . . .

"Application.CurrentProject.Path"

I have tried it in the On Open and On Load . . . but . . .

Well, you get the point . . . I am an idiot

Please guide me with your hand oh great weedhopper!


=P

Thanks
Chance~
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top