473,442 Members | 4,793 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Extracting/Updating SQL from a QueryDef

NeoPa
32,556 Expert Mod 16PB
To extract the SQL from a QueryDef (saved Access query) it is only necessary to view the query in SQL View. This shows the underlying SQL for the QueryDef and is in simple text form (See Access QueryDefs Mis-save Subquery SQL for problems that may occur with SubQueries in your SQL). When a QueryDef is open (either in Design View or Datasheet View) it is possible to switch to the SQL View simply by selecting View \ SQL View from the menu.

From here it is simple to Copy & Paste it to wherever you need it. Please remember it is always better to post Copy/Pasted work here at Bytes to avoid any inadvertent mistakes that can waste much time.

It is also possible to paste (or simply type) SQL into a QueryDef in this way. Be careful though. Once the SQL has been updated this way Access will disallow viewing the QueryDef in Design View unless the SQL is found to be valid and of a displayable type (UNION queries are the most common of non-displayable types). Sub-queries (Subqueries in SQL) can be handled in Design View. The sub-query is simply displayed as any other record source.

It is wise to switch back to Design View to check the SQL is valid (and test it where possible) before saving away your updated QueryDef. A QueryDef saved while in SQL View will open again in that view.
Oct 11 '11 #1
0 5362

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

Similar topics

0
by: Shaphe | last post by:
I have a system which allows a user to create a list of predefined reports to print. Each report has a chart object, all the chart objects have rowsource set to "ChartQuery". As I loop through...
2
by: bebelino | last post by:
Hello, this should be an easy one, but I've had always troubles with it. How to pass trough a querydef-variable, form-variable and so on from a function to the caller-routine? Is there a simply...
1
by: VBSponge | last post by:
Hi all. Need help here as I cant see whats wrong... I have a querydef in Access 2k which execs a stored proc in a SQL Server 2k db. I keep getting the following error, and cant stop it for the...
1
by: lgs | last post by:
In an application, I'm creating a QueryDef on the fly, then use DoCmd.OpenQuery to display the results. If the user changes column width, for example, s/he is prompted when closing whether s/he...
6
by: Tim Marshall | last post by:
A2003, but this behaviour also occurred during the same DAO process I'm about to describe in A97. I have a sub procedure which takes two arguments: a querydef name; and an SQL statement...
21
by: Marc DVer | last post by:
I am trying to create a query that can be loaded as a querydef object but not having to assign values to the parameters if I don't want to. Normally when using a parameter query in VBA my code...
4
by: sara | last post by:
Hi - All is fine if I open my form, do something, then close it. However, if I just open it, then press the Close button (or go into design view), I get "object variable or with Block variable...
11
by: Liam.M | last post by:
Hey guys, If anyone could spare sometime to help me out, it would be very much appreciated.....what I am trying to do is automate a "Command" that sends me an Email. I have created a Query that...
2
by: Tommy Hayes | last post by:
Hello all, I have the following code snippet in my Access app: Dim dbQueryDef As QueryDef Set dbQueryDef = CurrentDb.QueryDefs("QUERY_NAME") ' (1) Set dbQueryDef = CurrentDb.QueryDefs(26) '...
6
by: Werner | last post by:
Hi, I try to read (and extract) some "self extracting" zipefiles on a Windows system. The standard module zipefile seems not to be able to handle this. False Is there a wrapper or has...
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
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
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...
1
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
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
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,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.