CurrentProject method for Access '97 ?

Local time
Today, 04:55
Joined
Feb 25, 2008
Messages
410
Hi folks,

I'm trying to implement BobLarson's FE Autoupdate utility for an Access 97 database. The only problem (so far) is that '97 does not support the CurrentProject method.
(Specifically) CurrentProject.Path
and CurrentProject.Name

Does anybody know of a way around this?
 
Is CurrentDB the same?

No, it isn't.

You can use this function to get the path of the database:
Code:
Public Function GetDBPath() As String
    Dim strFullPath As String
    Dim I As Integer

    strFullPath = CurrentDb().Name

    For I = Len(strFullPath) To 1 Step - 1
        If Mid(strFullPath, I, 1) = "\" Then
            GetDBPath = Left(strFullPath, I)
            Exit For
        End If
    Next
End Function
 
Yeah, I saw that somewhere else too, but couldn't get it to work. I just don't have that much experience.
What I tried to do Bob, was in the code you paste into the form's load event... I tried to substitue "GetDbPath" any time I saw "CurrentProject.Path", but whereever there is "&" in the code, an error pops up and said something... I forgot... but it would always highlight the "&".

I'm actually at home right now, so I can get more details tomorrow morning if needed.
Thanks for everybodies help!
 
hi,

the GetDBPath code is almost right for you. the problem is that it leaves trailing '\' whereas currentproject.path does not, thus giving a bad path. For instance. If you database is C:\Databases\TestDB.mdb, CurrentProject.path gives you C:\Databases, wherease GetDBPath returns C:\Databases\. (notice the final '\'. All you need to do is alter 1 line in the code for GEtDBPath, as follows:
Code:
GetDBPath = Left(strFullPath, I)
should read
Code:
GetDBPath = Left(strFullPath, I - 1)

HTH,
Chris
 
Okay, cool.
That seems to be working.
Now I have to find a substitute for CurrentProject.Name

Would it be a variation of the strFullPath method?
Can I use CurrentDB.Name?
Let's find out!...
 
Last edited:
Found this function in the archives - see if it works:

Code:
Public Function GetdbName()
   GetdbName = Right(CurrentDb.Name, Len(CurrentDb.Name) - InStrR(CurrentDb.Name, "\", 1))
End Function
 
Awesome

That seems to work too.

I'm going to do a little more testing.

Thanks again everybody!
 
Last edited:
Okay, wasn't long before I found another bug:
1) When I try to compile a .mde from the master FE, it says:
"Compile error in hidden module: GetDbName

2) I tested the auto-update by changing the version number on the BE and the master FE, then I ran an "outdated' copy of the FE and I get the pop-up that says it is out of date and needs to update. I click okay, but then it says:
"Run-time error '424':
Object Required"

I have no idea what either of these mean!
 

Users who are viewing this thread

Back
Top Bottom