Access2000 code not working in Access97 (1 Viewer)

JSDoyle

Registered User.
Local time
Today, 00:26
Joined
Feb 4, 2000
Messages
10
I have code in a form that sets the path to images. It works fine in Access 2000.

When I run it in Access 97 I get a compile error, Sub or Function not defined and it hangs on the string "InStrRev". Is there an equivelent 97 instruction? The full expression set is below with the point of the error in bold.

Function setImagePath()
Dim strImagePath As String
Dim strMDBPath As String
Dim intSlashLoc As String

On Error Resume Next
'Obtain the full path of the current database or Access Project
strMDBPath = CurrentProject.FullName

'Find the location of the last backslash
intSlashLoc = InStrRev(strMDBPath, "\", Len(strMDBPath))

'Trim off the database name, leaving the path
'and append the name of the image file
strImagePath = Left(strMDBPath, intSlashLoc) & _
Me.Headstamp

'Set ImageFrame to the path of the image file
Me.ImageFrame.Picture = strImagePath
End Function


Thanks,

Scott Doyle
 

Travis

Registered User.
Local time
Yesterday, 16:26
Joined
Dec 17, 1999
Messages
1,332
See this Microsoft Knowledge base article (It deals with VB, but the code also works with Access 97)

HOWTO: Simulate Visual Basic 6.0 String Functions in VB5
ID: Q188007
 

JSDoyle

Registered User.
Local time
Today, 00:26
Joined
Feb 4, 2000
Messages
10
Thanks

Thanks for sharing the knowledge base article with me. If I can get that to work it will be a miracle.... but I've got lucky before!

Thanks again,

Scott
 

JSDoyle

Registered User.
Local time
Today, 00:26
Joined
Feb 4, 2000
Messages
10
problem

Well I plugged the code from the article into a module in my application. I immediately get a compile error that says "Automation type not supported in Visual Basic."

The code is right from the article and is suppose to be for Access 97.

I know enough about modules to be dangerous.
 

Travis

Registered User.
Local time
Yesterday, 16:26
Joined
Dec 17, 1999
Messages
1,332
Which Line did it bomb on (HighLight)
 

JSDoyle

Registered User.
Local time
Today, 00:26
Joined
Feb 4, 2000
Messages
10
I get the error and click OKAY, the entire line below is highlighted:

Public Function InStrRev(ByVal sIn As String, sFind As String, _
Optional nStart As Long = 1, Optional bCompare As _
VbCompareMethod = vbBinaryCompare) As Long

This is straight from the article and the error again is:

"Compile Error:

Automation Type not supported in Visual Basic"

Thanks!
 

JSDoyle

Registered User.
Local time
Today, 00:26
Joined
Feb 4, 2000
Messages
10
Here is the entire section taken from the KB article that I've plugged into a module

Public Function InStrRev(ByVal sIn As String, sFind As String, _
Optional nStart As Long = 1, Optional bCompare As _
VbCompareMethod = vbBinaryCompare) As Long
Dim nPos As Long
sIn = StrReverse(sIn)
sFind = StrReverse(sFind)
nPos = InStr(nStart, sIn, sFind, bCompare)
If nPos = 0 Then
InStrRev = 0
Else
InStrRev = Len(sIn) - nPos - Len(sFind) + 2
End If
End Function
 

Travis

Registered User.
Local time
Yesterday, 16:26
Joined
Dec 17, 1999
Messages
1,332
Did you bring over everything or just the RevInstr Function.

You need to bring over the entire code as there are Constants in the Declaration setion.
 

JSDoyle

Registered User.
Local time
Today, 00:26
Joined
Feb 4, 2000
Messages
10
Well I tried coping the entire code over first. That didn't work so I cut out everything except the code I was interested in.

Both had the same results. The entire first section was hilighted.

I followed the instruction on the KB article to a tee the first time but it had the error.

I'll do it again.

I've got the database set up to display two .jpgs on the form without having them in the datatable itself. Keeps the size of the database down as you know. The code that is in question just sets the path for the images relative to the location of the database. This allows for custom installs and such.

Thanks,

Scott
 

sambo

Registered User.
Local time
Yesterday, 16:26
Joined
Aug 29, 2002
Messages
289
Why not just use Application.CurrentProject.Path instead of getting the FullName and then extracting the path. You are adding a couple of unnecessary steps.
 

Users who are viewing this thread

Top Bottom