473,408 Members | 1,861 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,408 software developers and data experts.

read sql statement of a query using vba

24
Hello,
I have created a query in Access and I want to be able to read the sql statement of the query using vba and then run it from excel vba.
That is instead of copying and pasting all the query sql statements i want to use code to read it directly from vba. Or alternatively run from excel the query on a recordset without the sql statement.

Thank in advance
Tsigos
Sep 21 '07 #1
6 3043
NeoPa
32,556 Expert Mod 16PB
Each QueryDef (saved query) object in Access has a .SQL property with (strangely enough) the SQL string in it.
However, you're probably better off running the query remotely from Excel rather than trying to execute the same SQL. Syntax differs and so does the data sources that are available (and how they are referred to).
Sep 21 '07 #2
TSIGOS1
24
I have tried copying the code from access to excel vba and it works fine. No need to convert any references or like *.to % or anything. Since it works any ideas on how to get this code from querydefs???

Thanks again!!
Sep 21 '07 #3
Denburt
1,356 Expert 1GB
Since you haven't posted any code I really don't understand the question. I would simply link to the query Via Excel then use something to refresh it or re query in Excel when needed.
Sep 21 '07 #4
NeoPa
32,556 Expert Mod 16PB
I have tried copying the code from access to excel vba and it works fine. No need to convert any references or like *.to % or anything. Since it works any ideas on how to get this code from querydefs???

Thanks again!!
Please check out post #2 again. I answer that question as the first sentence (paragraph).
Sep 21 '07 #5
TSIGOS1
24
thanks vey much for the prompt replys
you pointed me directly, i hadn't use .sql statement before but now i figured out how it works.
Excellent job u do.
Thank again
Sep 21 '07 #6
NeoPa
32,556 Expert Mod 16PB
Thank you. You're welcome.
It's always nice to be appreciated.
Sep 21 '07 #7

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

Similar topics

4
by: francis70 | last post by:
Hi, I have these 2 problem? Is there a way in Oracle to read UNCOMMITED data. i.e. in Oracle the normal behaviour is that a user's updates to a table are visible to other users ONLY when the...
11
by: Markus Breuer | last post by:
I have a question about oracle commit and transactions. Following scenario: Process A performs a single sql-INSERT into a table and commits the transaction. Then he informs process B (ipc) to...
29
by: pb648174 | last post by:
I have a very long transaction that runs on the same database that other users need to use for existing data. I don't care if they see data from the transaction before it is done and am only using...
7
by: Bob | last post by:
Currently I am using this statement to translate 3 fields in my db thru Visual Basic. I import the data from one table to another then call the IFF statements and the NewDate to translate the...
7
by: mark | last post by:
Access 2000: I creating a report that has a record source built by the user who selects the WHERE values. An example is: SELECT * FROM CHARGELOG WHERE STDATE Between #10/27/2003# And...
4
by: Polly | last post by:
I had a macro that ran a parameter query and created and opened an Excel file with the system date as part of the file name, but I had to change the file name by hand. So I converted the macro to...
6
by: sghi | last post by:
Hi All, I'm new to this group and quite new to access/vba. So, shortly after beginning to write a simple application for my wife, I came across a blocking problem: I need to intercept the sql...
2
by: Robert | last post by:
I am trying to give the user dynamic search capabilities to select almost any record in the database from criteria they select. Everything seems to work except when I open the display form to...
2
by: cj | last post by:
How is the best way to return a single record via sql query that will result in me being able to read and change the values of the individual fields as needed as I proceed through a section of...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.