?
Solved

Running Access queries containing user defined functions in Excel

Posted on 2011-10-06
3
Medium Priority
?
568 Views
Last Modified: 2012-05-12
Hi, I have an Access database with queries which references user defined function located in a module in the database.  The query runs fine in Access.  

I would like to run this query from VBA Excel so I can dump the results into my spreadsheet.  However, I am getting an error saying that my user defined function cannot be found: Run-time error '3085'  Undefined function 'userfunction' in expression.

Is there a work around to this?  I tried cutting and pasting the Access vba code for that function into the Excel module, but am getting the same error.

Thanks in advance!  

Hammer8
0
Comment
Question by:Hammer8
3 Comments
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 1000 total points
ID: 36926199
How are you attempting to run it from Excel?

You'll need to automate Access.
0
 

Author Comment

by:Hammer8
ID: 36926226
Yes, trying to run it from Excel VBA.  What does automate from Access mean?  I need to initiate the query from Excel because my macro does more than just pull in the query in question.  Thanks.
0
 
LVL 85

Assisted Solution

by:Rory Archibald
Rory Archibald earned 1000 total points
ID: 36929222
What Patrick means is that you will need to have your code actually start Access and run the query in the Access application. You will not be able to use the queries as they stand outside of Access itself. Your alternative would be to pull in the raw data, without whatever processing the UDFs do, and then process it in Excel instead.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question