473,624 Members | 2,252 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extracting/Updating SQL from a QueryDef

NeoPa
32,567 Recognized Expert Moderator MVP
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 5392

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

Similar topics

0
2229
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 the list, printing the selected reports, I build the "ChartQuery" querydef by replacing certain key words in an SQL statement associated with the selected report with variable data set as the user selects the reports. Specifically, the user can...
2
3944
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 rule one should follow? eg. function test(a as integer) as querydef dim qdfOut as querydef dim qdf as querydef
1
4152
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 life of me: "Error 3146: ODBC Call Failed" Now, the stored proc uses @RETURN_VALUE to pass back an integer result
1
2101
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 wants to save the query. This doesn't work anyway, since it's just a temporary QueryDef, but I'd like to avoid the whole Save/Yes/No/Cancel dialog box entirely - it's just an annoying nuisance that could confuse some. The Updatable property of...
6
4175
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 constructed from the calling procedure and constructs or modifies a querydef. The sub runs through the querydefs collection - if it finds the querydef name argument, it takes the existing query and modifies the SQL. If not found, a new querydef is...
21
5751
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 would go something like this: dim qry as dao.querydef set qry = currentdb.querydefs("myquery") qry.parameters("Par1") = "blah"
4
3075
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 not set" error 91 on mqdf.Close The following code appears at the top of the module: (someone wrote it for me)
11
1928
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 grabs all the records I am after...now all I need to do is get some code that will allow me loop through each of these records shown by the query and pass certain fields from these records into the Body of my email command...which then emails...
2
6262
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) ' (2) Line (1) does not do as I expect it - it always returns the first
6
4442
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 some one experience with other libaries to
0
8242
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8177
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8629
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8488
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7170
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6112
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4183
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1793
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.