Problem calling a function (1 Viewer)

A

atienza

Guest
Hello everybody.

I've done a vba function in a database. I can use that function correctly in a query in my database to do what I want, but I need to execute the query with the function insede it from a standalone VB program (outside the database). I get an error: the function is not recognised. Does that mean I cannot use a function defined in a module calling it from a external program?

I would appreciate any suggestion from you, thanks very much.
 

charityg

Registered User.
Local time
Today, 07:48
Joined
Apr 17, 2001
Messages
634
I've never heard of anyone needing to do this. Can't you just copy the code into the other program to be able to use it?
 
A

atienza

Guest
No, I can't copy the function into the other program. To put it clearly I'll describe to you the exact problem:

I need to execute this query:

UPDATE Squid SET url = fntReplace(url,'|',';') WHERE url like '*,*'

to replace the ',' for ';' in the field url.

I've defined the function fntReplace in module in the DB, and it works properly if I execute the query by creating it manually in Access and clicking the button to execute it, but I need to execute this query from a VB external program, not a module.

And this code doesn't work in the VB program:

Set db = OpenDatabase("...", False, False)
db.Execute "UPDATE ..." 'The same than before

So my question is: Can't I execute a query containing a user-defined function in an external program? Can it be done only with the Access predefined functions?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 02:48
Joined
Feb 19, 2002
Messages
43,565
To make this work from VB I think you will need to use the Access application object to run the query.
 

chadt

Registered User.
Local time
Today, 07:48
Joined
Jan 9, 2001
Messages
20
Dim adpClientName As ADODB.Parameter
Dim strSearchName As String
strSearchName = txtSearch.Text & "%"
With cmd
Set .ActiveConnection = conn
.CommandText = "qrySearchClientName"
.CommandType = adCmdTable
Set adpClientName = .CreateParameter("OrganizationName", adChar, adParamInput, 50, strSearchName)
.Parameters.Append adpClientName
End With
Set madrClient = cmd.Execute
Call LoadClientNameInfolst
End If


This is how you call an access query form VB....if you need more help email me.

Of course you need you connection correct and declared along with the rs object.

Peace
 

Users who are viewing this thread

Top Bottom