473,405 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

how to pull Access query having UDF to excel ?

215 128KB
Currently I use indirect way to pull data to excel.
I create table and query result insert into it.
then pull data from that table to excel.

how can I get query result directly from access to excel ? (that query using UDF in access)
Dec 2 '15 #1
12 2811
zmbd
5,501 Expert Mod 4TB
HV,
You are going to have to give an example here... we don't usually write the code out and there will be specifics that may apply to your project.

However, with that said, this sounds like an application automation with Excel, something that you've shown in your other posts you have some familiarity with :)
Dec 2 '15 #2
hvsummer
215 128KB
No, I don't need code == I mean what method can get those data out from query that having UDF inside Access to excel ==

I can write code myself, just need the right way to go 0.0
Dec 2 '15 #3
mbizup
80 64KB
Try posting some specific examples...

Offhand, I'd suggest:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.TransferSpreadsheet  acExport, , YourQueryName,YourFilePath, True ' etc
Or automation code as zmbd suggested if you are not using a saved query, or if you need more customization. There are plenty of examples to be found out there with searches such as 'Export Access Recordset to Excel'

If those methods aren't working for you, let us know what specific problems you are encountering (or specific goals you are trying to reach)
Dec 2 '15 #4
jimatqsi
1,271 Expert 1GB
Maybe I'm out to lunch today and forgetting something obvious, but what is UDF?
Dec 2 '15 #5
mbizup
80 64KB
jimatqsi,

UDF = 'User Defined Function' (custom code)
Dec 2 '15 #6
hvsummer
215 128KB
Mbizup: Thank for reply, but that code won't work since I don't "export",
I need to "pull" data, mean the excel is exist and everything prepaired, just need data from Access lay on the sheet, that all ==

unlucky I can't use query connection or access's db connection because I used UDF on Saved query that block me to get data == don't tell me I have to use automaton access from excel 0.0 It like "turn on the light in the afternoob" ==
Dec 2 '15 #7
zmbd
5,501 Expert Mod 4TB
HV: Your function has to be executed in some fashion.
When your query is picked up by the ACE/JET/DBE and it encounters the UDF the DBE calls the VBA interpreter, passes any fields in the current record as needed, and waits for the returned value.

Now running the UDF in the query directly from Excel, from what I've read, has been disabled for security reasons.

You might be able to have the function ran within Access - make sure it is set as "PUBLIC' then one could try some basic application automation (I don't see an easy way around this):

Expand|Select|Wrap|Line Numbers
  1. Dim zAcc As Object
  2.  Set zAcc = CreateObject("Access.Application")
  3.  zAcc.OpenCurrentDatabase "FileNameAndPathGoHere"
  4.  zAcc.Run ("FunctionNameGoesHere")
  5.  if not zAcc Is Nothing then
  6.    zAcc.CloseCurrentDatabase
  7.    set zAcc = Nothing
  8.  end if
Along this same line, would could create sub that executes your query, pass in any augments (obj.run [procedurename],[aug1]...)... honestly, what you appear to be doing here is not something I've done before and really seems to be very, complex...
Dec 2 '15 #8
jforbes
1,107 Expert 1GB
I don't understand why you are moving your data around so much. Why don't you just use Access to create your Reports?
Dec 2 '15 #9
hvsummer
215 128KB
In my company I have to use excel to report. So that I prepair a template in excel that already have summary there, just need to get data out from access ==

If I could use Access report, I would please to do. unfornaturely, that's not my decision ==

@zmbd:
"Now running the UDF in the query directly from Excel, from what I've read, has been disabled for security reasons."

If it can be disabled then it can be enable, how to do that ?

btw, can ADO or DAO recordset open saved query to get data ?

I got to use UDF because Access don't have function I need ==
Like this, I have to report eachmonth, so query should get data from that month. Instead manually Month(BDate) = 11 each query, I call 1 UDF that get that month from Table1 through ADO.

I know I can use DLookup to do that but I have 2 or more UDF in used, so that just an example, that I need some function Access build-in can't provide
Dec 3 '15 #10
Rabbit
12,516 Expert Mod 8TB
What are the UDFs doing exactly?
Dec 3 '15 #11
MikeTheBike
639 Expert 512MB
Hi

I have written/crated dozens of reports in Excel usung data from Access and I invariable write the code in an Excel Module(s) providing buttons/UserForms for parameter selection etc (parameter retieved from the Access DB on the forms Initialize event obviously!).

To do this I use ADO connections and recordset objects.

The advantage I find in doing this is that I have total control over the report and its formatting; it also runs faster in Excel (that is a mystery but it usualy the case).
Some of these reports a quite large with 30 plus sheet and significant amounts of data.

The required query string(s) can (usually are) created in the Access query designer and pasted into Excel VBA (with mods to concatenate variable as necessary, particularly the wild card character in ADO i.e. uses %).

Virtually all the reports are created on the fly (only use template for complicated graph).

In my case this is almost essential as in some cases as I pull data from up to 4 Databases for a single report.

So, I would recommend this approach is considered in these circumstances.

Just to complete this little diatribe, I also use Excel to import data from excel spread sheet (generated by a financial/SQL database, again giving me total control over data validation etc. and the ability to save the data to the database structure as required.

Even when I do export data from within Access I always use automation (late binding) and never the built in DoCmd.TransferSpreadsheet. Again this eliminated any formatting issued etc.

btw, can ADO or DAO recordset open saved query to get data ?
Yes it can, it is treated just the same as a table (as it is in Access). However I always connect to the back end (its quicker) and stored queries are normally only in the front end, in which case I just use the stored query string in code as a sub-query.

Not sure if this is any help with the initial question, but I thought it might. I am sure other will have an opinion on this !!



MTB
Dec 3 '15 #12
hvsummer
215 128KB
@mikethebike:

wow, after I read your suggestion, I pop up new idea, why don't I copy my SQL stored to excel vba and copy those UDF in access to excel too lol, then I'll have a stored query inside Excel :D
Dec 3 '15 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: austin1539 | last post by:
I am trying to run an Access query from Excel. The query, called "ProdActs1" works in Access and is run from using information from a table called "Queries". When a button is clicked in Excel, data...
7
by: tasmontique | last post by:
Hi All, I have finally succeeded in exporting to a preformated excel spreadsheet. I have one tiny setback. One of the sheets I am exporting to must be password protected. When I do this and...
1
by: CoolFactor | last post by:
MY CODE IS NEAR THE BOTTOM I want to export this Access query into Excel using a command button on an Access form in the following way I describe below. Below you will find the simple query I am...
12
by: TARHEELS721 | last post by:
I am trying to send the results of a query that runs when I click a button on my form that is based on a parameter query. The code runs without any errors but nothing is exported into my excel...
4
by: pkj7461 | last post by:
Hi, I was using Docmd.Transferspreadsheet to to populate query data in Excel. My code so far Dim xlApp As Excel.Application Dim xlWb As Excel.workbook Dim xlWs As Excel.Worksheet Set x1App =...
2
by: Comandur | last post by:
Hi, I am trying to export an access query to excel. I have made use of transferspreadsheet command to achive this. However i have hardcoded the path and the filename in the VBA code. I am not sure...
2
by: Marisol2 | last post by:
I have some queries in Access 2003 db that I have setup to display as pivots. I can go into design pivot table view and click on and then click on Export to Office MicroSoft Excel. The problem is I...
3
by: JimCarlson | last post by:
I've created a macro in Access 2003 to output a query into Excel. I have scheduled a Windows XP task to run daily to run the macro. I want the current values in the query to overwrite the current...
2
by: Amin Bardai | last post by:
How about this: I want to export results of an MS-Access query into an existing XLS template using TransferSpreadsheet method? I can create a new XLS file but I just want to append records from...
13
by: Malungo1970 | last post by:
Hi Everyone, I'm using a code to export a query from Access to create a new Excel with 1 Sheet and Protect with password, and everything's right. Private Sub botton_Click() On Error GoTo...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.