Access 97 conversion old DLL Entry point

L

L. Sall

I have recently aquired a project written in Access 97. In the project there
are declares for dll entry point into Access.exe which under XP kick out
errors as not existing. The entry points are:

accFileExists Lib "msaccess.exe" Alias "#57"
accFullPath Lib "msaccess.exe" Alias "#58"
accSplitPath Lib "msaccess.exe" Alias "#59"

Are there replacements in access XP, 2003? A VB solution I know exists but
is there one in VBA?
 
D

Douglas J. Steele

As undocumented entry points, there's never been any guarantee that they'll
continue to be valid.

If you know a VB solution, why can't you use that in VBA?
 
L

L. Sall

Not all VB functions work in VBA... I just wanted to know if there are now
Access Replacements or a VBA equiv. I use VB alot and find thing like
FileExists in VB has given me alot of Grief. I've coded a solution that
doesn't send the end app into fit of silence but I have seen the solution
during developemnet cause my AV to flag illeagle access. Since this is going
into a less than user environment I just want to be sure the next guy who
needs to modify the code will not have deciper, as I am, someone else's
Undocumented code.

I did relize the functions were undocumented... that's why I'm here.... It
is pretty easy to guess what they do I just want to know if Access 2000
exposes any functionality that will effectivly replace these. My goal is to
convert the Access Application not add 100 lines of code just to fix what is
there. Right now time is not on my side... I don't do much VBA in access
anymore Just VB. I was hoping somone might remember of something.
 
D

david epsom dot com dot au

Entry points like that were used in Access 2.0 because
Windows 3.1 did not have an API which provided those
functions. If you don't wish to use VB code, you should
replace them with standard Windows API calls.

AFAIK The Access Application object and the VBA object
don't explicitly have a FullPath or a SplitPath function.

(david)
 
J

Jeff Conrad

in message:
I have recently acquired a project written in Access 97. In the project there
are declares for dll entry point into Access.exe which under XP kick out
errors as not existing. The entry points are:

accFileExists Lib "msaccess.exe" Alias "#57"
accFullPath Lib "msaccess.exe" Alias "#58"
accSplitPath Lib "msaccess.exe" Alias "#59"

Are there replacements in access XP, 2003? A VB solution I know exists but
is there one in VBA?

Boy does this ever ring a bell!

I ran into almost the exact same issue for an add-in I have been working on.
I was trying to modify some 97 wizard code and ran into several problems
with converting entry points that were dropped in later versions. MVP Dirk
Goldgar was kind enough to piece together some code to do the same thing
as entry point 59. When I'm back down in the office tomorrow I will dig around
and find it for you.
 
J

Jeff Conrad

Ok, here is replacement code for Access 97 Entry Point 59,
care of MVP Dirk Goldgar:

'----- start of code -----
Sub SplitPath( _
ByVal FilePath, _
ByRef strDrive As String, _
ByRef strFolder As String, _
ByRef strFilename As String, _
ByRef strExtension As String)

strDrive = fncSplitString(FilePath, ":")
If Len(FilePath) = 0 Then
FilePath = strDrive
strDrive = vbNullString
End If

strFolder = StrReverse(FilePath)

strFilename = fncSplitString(strFolder, "\")
If Len(strFolder) > 0 Then
strFolder = StrReverse(strFolder)
End If

strExtension = fncSplitString(strFilename, ".")
If Len(strFilename) = 0 Then
strFilename = StrReverse(strExtension)
strExtension = vbNullString
Else
strExtension = StrReverse(strExtension)
strFilename = StrReverse(strFilename)
End If

End Sub


Function fncSplitString(ByRef SourceString, ByVal Delimiter, _
Optional Compare As Integer = vbBinaryCompare) _
As String

' Splits <SourceString> at the first occurrence of
' <Delimiter>, returning all characters up to but not
' including <Delimiter>, and removing those
' characters plus the following <Delimiter> from <SourceString>. If
' <Delimiter> is not found, all of <SourceString> is returned, and
' <SourceString> is set to a zero-length string. The optional
' Parameter <Compare> may be specified to control whether a binary
' or text comparison is used to search for <Delimiter>, using the
' same values as are accepted by the Instr() function.

Dim lngPos As Long

lngPos = InStr(1, SourceString, Delimiter, Compare)

If lngPos = 0 Then
fncSplitString = SourceString
SourceString = ""
Else
fncSplitString = Left$(SourceString, lngPos - 1)
SourceString = Mid$(SourceString, lngPos + 1)
End If

End Function
'----- end of code -----


'Here's a routine to test it out:

'----- start of tester code -----
Sub SplitPathTest()

Dim strPath As String
Dim strDrive As String
Dim strFolder As String
Dim strFilename As String
Dim strFileExt As String

Do
strPath = InputBox("Enter path to parse:")
If Len(strPath) > 0 Then
SplitPath strPath, strDrive, strFolder, _
strFilename, strFileExt

MsgBox _
"drive=" & strDrive & vbCr & _
"folder=" & strFolder & vbCr & _
"filename=" & strFilename & vbCr & _
"extension=" & strFileExt
Else
Exit Do
End If
Loop

End Sub
'----- end of tester code -------

Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
Hope that gets you going,
--
Jeff Conrad
Access Junkie
Bend, Oregon

in message:
 
L

L. Sall

Jeff thanks... You would not happen to have replacements on hand for the
other two functions?

Jeff Conrad said:
Ok, here is replacement code for Access 97 Entry Point 59,
care of MVP Dirk Goldgar:

'----- start of code -----
Sub SplitPath( _
ByVal FilePath, _
ByRef strDrive As String, _
ByRef strFolder As String, _
ByRef strFilename As String, _
ByRef strExtension As String)

strDrive = fncSplitString(FilePath, ":")
If Len(FilePath) = 0 Then
FilePath = strDrive
strDrive = vbNullString
End If

strFolder = StrReverse(FilePath)

strFilename = fncSplitString(strFolder, "\")
If Len(strFolder) > 0 Then
strFolder = StrReverse(strFolder)
End If

strExtension = fncSplitString(strFilename, ".")
If Len(strFilename) = 0 Then
strFilename = StrReverse(strExtension)
strExtension = vbNullString
Else
strExtension = StrReverse(strExtension)
strFilename = StrReverse(strFilename)
End If

End Sub


Function fncSplitString(ByRef SourceString, ByVal Delimiter, _
Optional Compare As Integer = vbBinaryCompare) _
As String

' Splits <SourceString> at the first occurrence of
' <Delimiter>, returning all characters up to but not
' including <Delimiter>, and removing those
' characters plus the following <Delimiter> from <SourceString>. If
' <Delimiter> is not found, all of <SourceString> is returned, and
' <SourceString> is set to a zero-length string. The optional
' Parameter <Compare> may be specified to control whether a binary
' or text comparison is used to search for <Delimiter>, using the
' same values as are accepted by the Instr() function.

Dim lngPos As Long

lngPos = InStr(1, SourceString, Delimiter, Compare)

If lngPos = 0 Then
fncSplitString = SourceString
SourceString = ""
Else
fncSplitString = Left$(SourceString, lngPos - 1)
SourceString = Mid$(SourceString, lngPos + 1)
End If

End Function
'----- end of code -----


'Here's a routine to test it out:

'----- start of tester code -----
Sub SplitPathTest()

Dim strPath As String
Dim strDrive As String
Dim strFolder As String
Dim strFilename As String
Dim strFileExt As String

Do
strPath = InputBox("Enter path to parse:")
If Len(strPath) > 0 Then
SplitPath strPath, strDrive, strFolder, _
strFilename, strFileExt

MsgBox _
"drive=" & strDrive & vbCr & _
"folder=" & strFolder & vbCr & _
"filename=" & strFilename & vbCr & _
"extension=" & strFileExt
Else
Exit Do
End If
Loop

End Sub
'----- end of tester code -------

Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
Hope that gets you going,
--
Jeff Conrad
Access Junkie
Bend, Oregon

in message:
 
D

Douglas J. Steele

What are the functions supposed to do?

If accFileExists is supposed to indicate whether or not a particular file
exists, Len(Dir(filename)) > 0 will give you that.

You've already been given an equivalent for accSplitPath: what's accFullPath
supposed to be?
 
J

Jeff Conrad

in message:
Jeff thanks... You would not happen to have replacements on hand for the
other two functions?

No, I do have replacements handy.

As Doug has already mentioned, the Len function should help with
finding out if a particular file exists.
 

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