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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 97 get just the name / title of the database not the full path

Status
Not open for further replies.

scottian

Programmer
Jul 3, 2003
955
GB
Ive searched here but didnt find an answer. Ive had to make one of my own, but i thought maybe others might find this solution usefull. I needed to get just the name / title of the database not the full path but Access 97 doesnt have the 'InStrRev' function , thats why i needed to do this. Its a bit grubby but it works for me, if anyone can make it neater and more efficient, please feel free to do so.

Function GetDB_Name()
Dim DbNameString
Dim What2Look4
'gets the length of the database name
'i.e. C:\my drive\my database.mdb
DbNameString = InStr(1, CurrentDb.Name, ".mdb")
What2Look4 = Mid(CurrentDb.Name, DbNameString - 1, 1)
'loop until the last backslash in the database name is found
Do Until What2Look4 = "\"
FDbNameString = DbNameString - 1
What2Look4 = Mid(CurrentDb.Name, DbNameString, 1)
Loop
MsgBox Mid(CurrentDb.Name, DbNameString + 1, DbNameString)
End Function

"Children are smarter than any of us. Know how I know that? I don't know one child with a full time job and children."...Bill Hicks
 
How about Right(CurrentProject.FullName,len(CurrentProject.FullName-len(CurrentProject.Path))
 
Or am I being daft and using stuff that isn't in 97. I'm assuming so since you'd have just used currentproject.name if it was available.
 
Rivethed,
your right, i did try currentproject.name but got an error - 'variable not defined'

"Children are smarter than any of us. Know how I know that? I don't know one child with a full time job and children."...Bill Hicks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top