Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem using user-defined function in query run with Execute method

Status
Not open for further replies.

wemeier

IS-IT--Management
Aug 15, 2001
324
US
I have VB code behind a form that uses the Execute method to run a query:

db.Execute "qryAppendMovement"

Within that query I reference a user-defined function named GTIN2UPC that I wrote.

In one database the code executes perfectly. I put the form, the query and the function into a second database and now, every time I run the code I get an error:

Undefined function 'GTIN2UPC' in expression.

What am I missing?


[shadeshappy] Cruising the Information Superhighway at the speed of light
[sub] (your mileage may vary)[/sub]
 
Access to functions are in the local database only. You'll have to have the same function defined in your second database for it to work.
 
ImHuman,

I said in my post that I copied the function into the new database as well. That's why I'm perplexed. I even checked all VB library references to make sure they were the same.

[shadeshappy] Cruising the Information Superhighway at the speed of light
[sub] (your mileage may vary)[/sub]
 
So if you open an immediate window in VBA and just prod your function from there it works ok? Is it declared as a public function in the second db? Is it in a module or in the codde of a form? Just chucking some ideas around here....

JB
 
If I open the query that uses the function and run it, it works just fine. If I use Docmd.OpenQuery it works just fine. If I use DoCmd.RunSQL followed by the SQL code it works fine. Just using it with the .Execute method fails.

I know .Execute has some limitations that the others don't -- especially regarding VBA -- but it's working in another database!

[shadeshappy] Cruising the Information Superhighway at the speed of light
[sub] (your mileage may vary)[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top