473,796 Members | 2,455 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how do I keep the query result when I switch to design view?

When I swtich to design view from data view, the query results are
lost, and I have to run again to get it. Is there an option in access
to keep the data when I switching views? I know I can copy them to
other place, such as excel, but I'd prefer to keep them in access.

thanks,

Wei

Sep 14 '06 #1
7 1689
What you're asking doesn't make sense. A query is a *definition* of a
resultset, and *not* the results themselves. If you want to save the
information somewhere,you'l l have to write them to a table or
something. In short, no. once you close the query or return to design
view, the dataset is no longer available.

Sep 14 '06 #2
It does make sense, I wanna switch between design/sql and data view so
I can revise a query based on the previous data. and I only want the
updated resultset when I need to.

pi********@hotm ail.com wrote:
What you're asking doesn't make sense. A query is a *definition* of a
resultset, and *not* the results themselves. If you want to save the
information somewhere,you'l l have to write them to a table or
something. In short, no. once you close the query or return to design
view, the dataset is no longer available.
Sep 14 '06 #3

zwa...@gmail.co m wrote:
It does make sense, I wanna switch between design/sql and data view so
I can revise a query based on the previous data. and I only want the
updated resultset when I need to.
You can't do that. A query is a DEFINITION ONLY. You'll have to put
the results somewhere that's static, like a table. Otherwise, you
can't do it. What the query returns when you run it is the resultset
that the query defines. There's an example of how to do what you want
in Access Developer's Handbook (Desktop). It's in one of the first few
chapters (the one on SQL). Other than that, I don't know how to do it.
Basically the way they solve it is to set the rowsource of the unbound
subform to the contents of the textbox at the top of the form. I think
you can download it from www.developershandbook.com

Don't think so... but it's on the ADH CD that comes with the book.
Only downside to ADH is that it is NOT a beginner book. Once you have
a pretty good handle on Access, it's a terrific book... but if you
don't have the basics down, it's a large paperweight.

Sep 14 '06 #4
zw****@gmail.co m wrote:
It does make sense, I wanna switch between design/sql and data view so
I can revise a query based on the previous data. and I only want the
updated resultset when I need to.

pi********@hotm ail.com wrote:
>What you're asking doesn't make sense. A query is a *definition* of a
resultset, and *not* the results themselves. If you want to save the
information somewhere,you'l l have to write them to a table or
something. In short, no. once you close the query or return to design
view, the dataset is no longer available.
Makes sense to me as well, and perhaps you know as I do that some
environments save query results in new and separate windows from the
SQL, allowing you to toggle back and forth. Alas, Access does not work
this way.

--
Smartin
Sep 14 '06 #5
No, not natively, you would have to persist the resultset somewhere and then
switch to design view.

--

Terry Kreft
<zw****@gmail.c omwrote in message
news:11******** **************@ e3g2000cwe.goog legroups.com...
When I swtich to design view from data view, the query results are
lost, and I have to run again to get it. Is there an option in access
to keep the data when I switching views? I know I can copy them to
other place, such as excel, but I'd prefer to keep them in access.

thanks,

Wei

Sep 15 '06 #6

Terry Kreft wrote:
No, not natively, you would have to persist the resultset somewhere and then
switch to design view.
Terry,

do you have a quick example of doing that?

thanks,
Pieter

Sep 17 '06 #7
Knocked up this morning, so it's pretty rough.

e.g. It doesn't check that the queries are actually select queries and I'm
sure there are a bunch of bugs in it.
' PersistQueries: Allows you to persist all open queries to tables
' ClearTmpTables: Removes all temp tables created by PersistQueries
Option Compare Database
Option Explicit

Private Declare Function EnumChildWindow s _
Lib "user32" (ByVal hWndParent As Long, _
ByVal lpEnumFunc As Long, _
ByVal lParam As Any) As Long
Private Declare Function GetWindowText _
Lib "user32" Alias "GetWindowTextA " _
(ByVal hwnd As Long, ByVal lpString As String, _
ByVal cch As Long) As Long
Private Declare Function GetTopWindow _
Lib "user32" ( _
ByVal hwnd As Long _
) As Long
Private Declare Function GetWindow _
Lib "user32" ( _
ByVal hwnd As Long, ByVal wCmd As Long _
) As Long
Private Declare Function GetClassName _
Lib "user32" Alias "GetClassNa meA" ( _
ByVal hwnd As Long, ByVal lpClassName As String, _
ByVal nMaxCount As Long _
) As Long
' *************** *************** *******
'

Function PersistQueries( ) As String
Dim colQueries As Collection
Dim varValue As Variant

Set colQueries = EnumChild
For Each varValue In colQueries
Call PersistQry(Trim (Left(varValue( 1), InStr(varValue( 1), ":") - 1)))
Next
End Function

Function ClearTmpTables( )
Dim intCount As Integer
Dim loTab As DAO.TableDef
Dim loProp As DAO.Property
Dim db As DAO.Database
Dim strTab As String

Set db = CurrentDb
For intCount = db.TableDefs.Co unt - 1 To 0 Step -1
Set loTab = db.TableDefs(in tCount)

For Each loProp In loTab.Propertie s
If loProp.Name = "Temp" Then
If loProp.Value = True Then
On Error Resume Next
db.Execute "DROP TABLE " & loTab.Name
On Error GoTo 0
End If
End If
Next
Next
Set loTab = Nothing
Set db = Nothing
End Function

Private Sub PersistQry(strQ DF As String)
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim loTab As DAO.TableDef
Dim strSQl As String
Dim strTab As String
Dim varSQL As Variant

Const SQL_INTO = " INTO "
Const SQL_FROM1 = vbCrLf & "FROM "
Const SQL_FROM2 = " FROM "

Set db = CurrentDb

Set qdf = db.QueryDefs(st rQDF)

strSQl = qdf.SQL

qdf.Close
Set qdf = Nothing

strTab = "tmp_" & Hex(CLng(Time * 10 ^ 7)) & "_" & strQDF

If InStr(1, strSQl, SQL_FROM1, vbTextCompare) 0 Then
varSQL = Split(strSQl, SQL_FROM1)
strSQl = varSQL(0) & SQL_INTO & strTab & SQL_FROM1 & varSQL(1)
ElseIf InStr(1, strSQl, SQL_FROM2, vbTextCompare) 0 Then
varSQL = Split(strSQl, SQL_FROM2)
strSQl = varSQL(0) & SQL_INTO & strTab & SQL_FROM2 & varSQL(1)
End If

db.Execute strSQl

Set loTab = db.TableDefs(st rTab)
With loTab
.Properties.App end .CreateProperty ("Temp", dbBoolean, True, False)
End With
Set loTab = Nothing
Set db = Nothing

DoCmd.OpenTable strTab, acViewNormal, acReadOnly

End Sub
Function EnumChild() As Collection
Dim varItem As Variant
Dim colChildWins As Collection
Dim intCount As Integer

Const WIN_CLASS_QUERY = "OQry"

Set colChildWins = New Collection
Call EnumChildWindow s(hWndAccessApp , AddressOf EnumWindowsProc ,
colChildWins)
For intCount = colChildWins.Co unt To 1 Step -1
varItem = colChildWins(in tCount)
If varItem(2) <WIN_CLASS_QUER Y Then
colChildWins.Re move intCount
End If
Next
Set EnumChild = colChildWins
End Function

Function EnumWindowsProc (ByVal hwnd As Long, ByVal lParam As Collection) As
Long
Dim lpString As String, cch As Long
Dim lpClassName As String, nMaxCount As Long
Dim lngret As Long
Dim cWI As Variant

cch = 260
lpString = String(cch, 0)
lngret = GetWindowText(h wnd, lpString, cch)
If lngret 0 Then
lpString = Left(lpString, lngret)

nMaxCount = 260
lpClassName = Space(nMaxCount )
lngret = GetClassName(hw nd, lpClassName, nMaxCount)
lpClassName = Left(lpClassNam e, lngret)

cWI = Array(hwnd, lpString, lpClassName)
lParam.Add cWI
End If
EnumWindowsProc = True
End Function


--

Terry Kreft
<pi********@hot mail.comwrote in message
news:11******** **************@ m73g2000cwd.goo glegroups.com.. .
>
Terry Kreft wrote:
No, not natively, you would have to persist the resultset somewhere and
then
switch to design view.
Terry,

do you have a quick example of doing that?

thanks,
Pieter

Sep 18 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
4570
by: Ryan | last post by:
I came across a situation that I've been unable to explain and was hoping somebody had an answer: I had written an update query which was taking about 8 seconds to run and considered it too slow. I copied the SQL statement from the query and tried executing it from code which then ran in 1 second. To make sure that I didn't miss anything, I copied the SQL statement back into a query and tried running it again. It now also only took 1...
8
6463
by: Adam Louis | last post by:
I would like help resolving this problem. I'm a novice who's been hired to query a hospital database and extract useful information, available to me only in a dynamically generated, downloadable .mdb. The query below query runs correctly and without error, but any attempt to save it causes Access to crash without a message, leaving the .ldb file. Opening the DB reveals it saved a blank "query1". I've upgraded to Jet SP 8, and I'm running...
3
579
by: John young | last post by:
I have been looking for an answer to a problem and have found this group and hope you can assist . I have been re doing a data base I have made for a car club I am with and have been trying to make a query that selects from a table as desribed below .. I have a table (Volunteer) that has a member field (memnumber) and a number of fields that are headed in various categories and are yes/no formated
4
1450
by: Philippe | last post by:
Hello, I encounter a problem that I cannot solve myself... The problem is the following: I make a table: several records: the first field is always a number, the following field is always an address
2
6181
by: Michael Donahoe | last post by:
I have a database that I inherited that has query in it that has hidden fields when it is in design view. Datasheet view shows the fields and when I switch back to design view it appears as though those columns are compressed. If I try clicking between the columns "<-|->" it does not do anything. I don't have 'Format' in the menu bar to unhide any of the fields for design view. Does anyone know how to unhide these columns?
6
4851
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID SalesManName AT Alan Time
1
1451
by: Regnab | last post by:
I often want to query the database with certain parameters in my query which I do not want included in the query result. The problem is when I want to group on 1, sum the 2nd (and group by) and use a parameter on the 3rd (but don't want to group by it). For example, I might want all records later than a certain date, but don't want to group on the date. In the past I've made 2 queries, the first choosing the records with the date...
3
7774
by: mnjkahn via AccessMonster.com | last post by:
I'm running Access 2003, modifying a query that has over 45 fields. When I right click on the field name in Query Design View, and then click Build, Access crashes before the Build window appears. It doesn't happen every time, and using the Zoom window works fine. It appears that it only happens when I want to modify an existing expression. This continues to happen even after the database is repaired and reopened. Anyone have any...
1
3549
by: david.triplett | last post by:
I am using MS Access 2007 and have an issue with writing queries against ODBC connected tables. After providing the appropriate ODBC connection string in the properties page, the Show Tables dialog will list the tables in the source database. When selecting a table to add to the design window the requested table will appear on the page but then disappear in the blink of an eye. I am unable to get the ODBC tables to "stick" to the page...
0
9680
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
9528
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,...
1
10173
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9052
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
7547
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
6788
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.