473,473 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Using one Form to view different queries

Wondering if it is possible to use one form to open different
queries at different times. As an example, I may have
frmViewQueries that opens up when I click a command button on
frmMain. So, the code for the command button might be

DoCmd.OpenForm "frmViewQueries", acFormDS

So, frmViewQueries actually provides a datasheet view of qryQuery1.

Now, what if later on I want to open qryQuery2 in the same
frmViewQueries form. Is this possible? Can I change the
RecordSource of frmViewQueries some how? Something like this

frmViewQueries.RecordSource = qryQuery2
DoCmd.OpenForm "frmViewQueries", acFormDS

How can I tell frmViewQueries what columns from qryQuery2 to display?
Marcus
******

Nov 13 '05 #1
3 5655
Marcus wrote:
Wondering if it is possible to use one form to open different
queries at different times. As an example, I may have
frmViewQueries that opens up when I click a command button on
frmMain. So, the code for the command button might be

DoCmd.OpenForm "frmViewQueries", acFormDS

So, frmViewQueries actually provides a datasheet view of qryQuery1.

Now, what if later on I want to open qryQuery2 in the same
frmViewQueries form. Is this possible? Can I change the
RecordSource of frmViewQueries some how? Something like this

frmViewQueries.RecordSource = qryQuery2
DoCmd.OpenForm "frmViewQueries", acFormDS

How can I tell frmViewQueries what columns from qryQuery2 to display?


The .Recordsource property can be used to change the data source on the
fly but can only be used after the form is opened.

DoCmd.OpenForm "myform",acNormal,"MyQuery"

will open it with a different query. If your queries have the same
column names then this is no problem but if they're different then
you'll be stuck with either having to predefine what queries you can
use, bind controls to the columns and show/hide at runtime or else set
the .controlsource property of the controls at runtime.
--
[Oo=w=oO]

Nov 13 '05 #2
"Marcus" <to*******@yahoo.ca> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Wondering if it is possible to use one form to open different
queries at different times. As an example, I may have
frmViewQueries that opens up when I click a command button on
frmMain. So, the code for the command button might be

DoCmd.OpenForm "frmViewQueries", acFormDS

So, frmViewQueries actually provides a datasheet view of qryQuery1.

Now, what if later on I want to open qryQuery2 in the same
frmViewQueries form. Is this possible? Can I change the
RecordSource of frmViewQueries some how? Something like this

frmViewQueries.RecordSource = qryQuery2
DoCmd.OpenForm "frmViewQueries", acFormDS

How can I tell frmViewQueries what columns from qryQuery2 to display?
Marcus
******


If your different queries are all based upon the same table(s) and the only
differences between the queries are the "criteria", then you can open the
form with the recordset directly to the table and use the filter parameter
to select the desired criteria. Example:
DoCmd.OpenForm "frmViewQueries", acFormDS,,"Year(fldDate)=2004"
Fred Zuckerman


Nov 13 '05 #3
Marcus,
In the recent (11-05-2005) thread 'Datasheet forms and columnwidths' you will find an answer from Stephen Lebans where he refers to an article by Michael Kaplan. Read this article until the end.
Quote: "Access 2000 takes this a step further to support using tables and queries directly in the Subform control as a SourceObject."
I just tried and it works great. Set columnwidth to -2 and all queries will adjust themselves.
You can also control the fontsize and visibility and so on.
I you need code I can help but read the article and 'play with it'.

Arno R

"Marcus" <to*******@yahoo.ca> schreef in bericht news:11**********************@g43g2000cwa.googlegr oups.com...
Wondering if it is possible to use one form to open different
queries at different times. As an example, I may have
frmViewQueries that opens up when I click a command button on
frmMain. So, the code for the command button might be

DoCmd.OpenForm "frmViewQueries", acFormDS

So, frmViewQueries actually provides a datasheet view of qryQuery1.

Now, what if later on I want to open qryQuery2 in the same
frmViewQueries form. Is this possible? Can I change the
RecordSource of frmViewQueries some how? Something like this

frmViewQueries.RecordSource = qryQuery2
DoCmd.OpenForm "frmViewQueries", acFormDS

How can I tell frmViewQueries what columns from qryQuery2 to display?


Marcus
******

Nov 13 '05 #4

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

Similar topics

0
by: Marko Poutiainen | last post by:
Situation: We had to make our SQLServer 2000 database multi-lingual. That is, certain things (such as product names) in the database should be shown in the language the user is using (Finnish,...
2
by: Tom Cusick | last post by:
MS Access Version 2002 (10.4302.4291) SP-2 Windows XP Pro 2002 SP-1 ----------------------------------------------------------------- Ok my question is this. I have one form laid out the way I...
1
by: Simon Matthews | last post by:
Hope someone can help an Access beginner! I've just started keeping my surgical logbook on access and it's a simple flat-file affair. I have created several queries that will list cases...
10
by: glenn354 | last post by:
I have a form I would like to use in front of several queries. For example, I want to use frmA but only looking at the records retrieved by qryX. Then I want to use frmA again, but only looking at...
3
by: google | last post by:
I'm developing an application for use within my company in Access 2003. I'm new to '03, the application I did for my former employer was in '97. The two applications have similar functionality...
10
by: Robert | last post by:
How do you get an accurate count of the number of records returned from a query when using linked tables. I have an access 2003 database as a front end to another access 2003 database that...
3
accessbunnie
by: accessbunnie | last post by:
Hello Access Users! I am a bit of an Access novice and am currently creating a database and have come up against a huge (for me!) road block. I do not write in Access code and instead, tend to...
0
MMcCarthy
by: MMcCarthy | last post by:
Rather than using the Access design view change the view to SQL. I am going to attempt to outline the general syntax used for SQL queries in Access. Angle brackets <> are used in place of some...
10
by: RLN | last post by:
I have 4 queries and all 4 queries use different tables and pull different columns. Is it possible to have one Generic all Purpose form (frmGeneral) and on the fly at run time set frmGeneral's...
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
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: 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...
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...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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...

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.