undefined function replace in expression

N

NiteFly

Hello
i've read all the threads dealing with the subject.
I've written my wrapper to the native replace function.it works fine
inside access.
i've changed sandbox value to 0.
but the problem still persists.
in addiction now there is no REPLACE function, but MyReplace.
this is the access code
Option Compare Database

Public Function MyReplace(StringToSearchIn As String, _
StringToFind As String, _
ReplaceString As String, _
Optional StartHere As Integer = 1, _
Optional HowMany As Integer = -1, _
Optional CompareMode As VbCompareMethod = vbTextCompare) As String

MyReplace = Replace(StringToSearchIn, StringToFind, ReplaceString,
StartHere, HowMany, CompareMode)

End Function

Public Function DoNot() As Integer
DoNot = 1
End Function



this is my vb6 code

Dim aCnn As New ADODB.Connection
Dim aRst As New ADODB.Recordset
Dim SQL As String
Dim dq As String
Dim sa As String
Dim Filtro As String
Dim RepFiltro As String

dq = Chr(34)
sa = Chr(39)
Filtro = dq & sa & dq
RepFiltro = dq & dq

On Error GoTo 0
aCnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Sorgenti
\_Mei\Eco.mdb;Persist Security Info=False"
SQL = "Select * from Tab_Pazienti where MyReplace(Nome, " & Filtro
& "," & RepFiltro & ")=" & dq & "Massimo" & dq
aRst.Open SQL, aCnn, adOpenKeyset, adLockOptimistic, adCmdText


last statement raises error "undefined function MyReplace in
expression"

if i change last one with ' SQL = "Select donot()" ' i get
"undefined function donot in expression".
this is driving me crazy.

If i execute the SAME queries inside ACCESS all work fine.

where is my mistake ?
Please help me.
 
D

Douglas J. Steele

You cannot use user-defined functions in queries unless you run them from
inside of Access. This is because when you're running queries from outside
Access, you're only going through the Jet Engine, and it doesn't know
anything about user-defined functions.
 
N

NiteFly

On 15 Mar, 05:12, "Douglas J. Steele"
This is because when you're running queries from outside
Access, you're only going through the Jet Engine, and it doesn't know
anything about user-defined functions.

Thanks 4 your kind reply.
OK, if there is no other way, i'll change db.
Thanks again
 

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