.accde picks up function error (1 Viewer)

Mist

Registered User.
Local time
Today, 13:49
Joined
Mar 5, 2012
Messages
66
I use the following 'ParseString' function in a report application, which works well - until I create a .accde file from my .accdb database. When I ry to run any report that uses 'ParseString' from within the .accde file I get an error: "Undefined function 'ParseString' in expression. (Error 3085)"

Code:
Function ParseString(AnyString As String) As String
Dim tmpStr As String
Dim lngCount As Long
 
If Len(AnyString) = 0 Then
    ParseString = vbNullString
    Exit Function
End If
 
For lngCount = 1 To Len(AnyString)
    tmpStr = tmpStr & Mid(AnyString, lngCount, 1) & " "
Next
 
ParseString = Left(tmpStr, Len(tmpStr) - 1)
End Function

Can anyone spot the mistake? :(
 

jzwp22

Access Hobbyist
Local time
Today, 06:49
Joined
Mar 15, 2008
Messages
2,629
This is just a guess, but perhaps in compiling the database as an .accde file, it does not like that you have not explicitly defined the function as either Public or Private

I would try changing this:

Function ParseString(AnyString As String) As String


to this:

Public Function ParseString(AnyString As String) As String


You might also try to compile the .accdb database via the VBA window (debug-->compile) prior to creating the .accde to see if there are any other issues.
 

Mist

Registered User.
Local time
Today, 13:49
Joined
Mar 5, 2012
Messages
66
Thanks so much for your advice. As it turns out I did have the function declared as 'Public', (bad copy-and-paste, my bad), however, I tried the 'Debug-Compile Forms' route and, although it never indicated any errors, it fixed the problem. I noticed that the 'Compile Forms' option was greyed out and unselectable thereafter... my problem arose when I tried to run a macro to give a print preview and it did nothing. I had to remove the 'on error' and 'msgbox' lines to produce the 'undeclared function' error. Anyway it now works fine and I'll try to understand why as I go on. Thanks again. :)

PS. I also removed the 'Option Explicit' line from the
'Option Compare Database
Option Explicit'
lines at the header of my standard module.. maybe this also had something to do with it?
 
Last edited:

jzwp22

Access Hobbyist
Local time
Today, 06:49
Joined
Mar 15, 2008
Messages
2,629
Usually the option explicit helps you out by forcing you to declare your variables when you try to run the code. I'm not sure why removing it would help, it usually aids in compiling the database.

In any event, I'm glad you got it working.
 

Mist

Registered User.
Local time
Today, 13:49
Joined
Mar 5, 2012
Messages
66
:) ..it was the 'Debug - Compile forms' that did the trick.. I put the 'option explicit' bak and it still works. Thanx.
 

Users who are viewing this thread

Top Bottom