473,408 Members | 2,427 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.

Multiple queries based off of the same criteria (input)

Hello,

Is it possible to have just one criteria and have it apply to a group
of queries?

I am trying to create a report with the separate results of 4 queries
based on a prompt for the user to input (only once) a date. Is this
something that I program into the report?

Also, this is related but may require a separate posting, but can I do
this with a list box for the user to select a choice, such as
LastMonth, LastWeek, etc.?

Thanks for your help in advance,
Brett
Jun 27 '08 #1
5 8065
Often pays to create a date input form with FromDate & ToDate on it. The
underlying queries for the various reports will have criteria based on these
FromDate and ToDate on the form

You can have fun designing the form to get those 2 dates from combo boxes or
whatever, but I certainly would have a command button that set the ToDate to
Now()

HTH

Phil

"Brett" <br*********@gmail.comwrote in message
news:ef**********************************@d19g2000 prm.googlegroups.com...
Hello,

Is it possible to have just one criteria and have it apply to a group
of queries?

I am trying to create a report with the separate results of 4 queries
based on a prompt for the user to input (only once) a date. Is this
something that I program into the report?

Also, this is related but may require a separate posting, but can I do
this with a list box for the user to select a choice, such as
LastMonth, LastWeek, etc.?

Thanks for your help in advance,
Brett

Jun 27 '08 #2
On Sun, 25 May 2008 13:07:58 -0700 (PDT), Brett wrote:
Hello,

Is it possible to have just one criteria and have it apply to a group
of queries?

I am trying to create a report with the separate results of 4 queries
based on a prompt for the user to input (only once) a date. Is this
something that I program into the report?

Also, this is related but may require a separate posting, but can I do
this with a list box for the user to select a choice, such as
LastMonth, LastWeek, etc.?

Thanks for your help in advance,
Brett
It's not clear to me if you are running 4 different reports base on 4
different queries, or 1 report based upon 4 different queries.
The below assumes 4 reports. Just modify it if it is one report.
You'll need to use a form to do this.

First, create a query that will display the fields you wish to show in
the reports.

Second, create a report, using the query(ies) as it's record source,
that shows the data you wish to display for ALL records.

Next, make a new unbound form.

Add 2 unbound text controls to the form.
Set their Format property to any valid date format.
Name one "StartDate".
Name the other "EndDate".

Add a command button to the form.
Code the button's Click event:
Me.Visible = False
Name this form "ParamForm"

Go back to the query.
As Criteria on the DateField, write:
Between forms!ParamForm!StartDate and forms!ParamForm!EndDate

Do the same for each query that is used in each of the reports.

Then on the first report that is run, code that Report's Open Event:
DoCmd.OpenForm "ParamForm" , , , , , acDialog

On the final report that is run, code that Report's Close event:
DoCmd.Close acForm, "ParamForm"

Run the first Report.
The report will open the form.

Enter the starting and ending dates.
Click the command button.

The first Report will display just those records selected.
Open each additional report in this series.

When the final Report closes it will close the form.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Jun 27 '08 #3
>but I certainly would have a command button that set the ToDate to
Now()
I think you meant to use the date function in the above, want to avoid using
the now() function if you do not need it.

You can mess up your dates in a database is to start using now() as the
default for your date fields. The now function include the date + time
portion

This means virtually any query that you build to test for a date set via
now() will have to include the correct time also.
eg:

select * from tblCustomers with MembershipDate = #10/01/2007 12:43 PM"

I suspect we actually don't really quite remember what time the customer
became an active member.

So, use caution in using date() functon vs that of Now().

if your dates all have a time component attached to them, and you have to
use a time/date range to select dates in your query...
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
Jun 27 '08 #4
Culpa mia

You're absolutely right ... as usual

Phil
"Albert D. Kallal" <Pl*******************@msn.comwrote in message
news:Lnp_j.164973$rd2.62016@pd7urf3no...
>
>>but I certainly would have a command button that set the ToDate to
Now()

I think you meant to use the date function in the above, want to avoid
using the now() function if you do not need it.

You can mess up your dates in a database is to start using now() as the
default for your date fields. The now function include the date + time
portion

This means virtually any query that you build to test for a date set via
now() will have to include the correct time also.
eg:

select * from tblCustomers with MembershipDate = #10/01/2007 12:43 PM"

I suspect we actually don't really quite remember what time the customer
became an active member.

So, use caution in using date() functon vs that of Now().

if your dates all have a time component attached to them, and you have to
use a time/date range to select dates in your query...
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com


Jun 27 '08 #5
Thanks again for your responses. I will provide a little more
information to clarify what it is that I am trying to do. I am
creating one report with several columns that pull data from 3
different tables and are based on different date parameters. I am
pulling the data from QuickBooks via ODBC and the date format data
returned is in the format m/dd/yyyy or mm/dd/yyyy.

One column will show the sum of all line items (SalesOrderLine.Amount)
based on all sales orders with the ShipDate that contains the current
month.

Another column will show the sum for all sales orders with ShipDate
for the beginning of the following month and beyond.

Another column will show the sum of all line items
(InvoiceLine.Amount) for all invoices with the TxnDate for the current
month.

Another column for all invoices with the TxnDate for same month last
year as the current month.

Another column for all invoices with the TxnDate from the beginning of
last year until the same day last year as the current day when the
report is ran.
I have tried using the Date() function as both a parameter or as part
of a build expression in a query, but I get an ODBC conversion error.
I have also tried using the Month() function, but it gives me 12 rows
of data, the sum for each month when I only want the current month,
Month = 6 for June, for example.

A few questions: should I be using a date prompt (From and To) for the
current month in the report? Should I be using any date parameters in
the queries or should that be done in the report itself and how is
that done?

Any resources you can provide where I can also learn how to do this,
which seems pretty complex, would be appreciated.

Brett

Jun 27 '08 #6

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

Similar topics

3
by: Gord | last post by:
I would like to create a summary report from the results of 11 queries (based on 2 tables). All the queries have the same format and return 3 numbers (Count, Current Year Bal, Last Year Bal.)...
1
by: mattcatmattcat | last post by:
I have a VB7 aspx file I am creating that requires multiple queries each dependant on the previous queries results. If I run these queries in foxpro, I just run a query then create a cursor with...
1
by: Bob Sanderson | last post by:
I am relatively new to PHP and MySQL. This is the first time I've tried to use multiple queries in a single script. I have the following PHP script which gets a Job Number from a search form and...
7
by: vaiism | last post by:
I am creating a report that outputs the contact information and details about a water treatment plant, and needs to include information about people who work there. If I tie all the information...
4
by: Akhenaten | last post by:
I am currently using enterprise manager to run multiple queries on a single table in a DB. I refresh these queries every few minutes. Due to the huge number of them I was looking for a better way...
3
by: Brett Barry: Go Get Geek! | last post by:
Hello, I just started using Access 2007 after using Access 2003 for a long time. I've created all my queries and they work fine. However, either I forgot or it has changed but, how do I create a...
0
by: JZNYC | last post by:
Hi, I am trying to fix some problems in an existing Access database. There is this report which has a few subreports embeded in it, which pull data from corresponding queries. The criteria for...
2
by: DigiLife | last post by:
Greetings all, I am trying to create a form in access 2007 that will return multiple queries (count). I have an appointment table and based off of the date selection I want a grid similar to "Cheap...
4
by: BigMac4 | last post by:
Ok i am going to sound like the novice i am but i am hoping that someone will take pity on me and help me out. Here is what i am trying to acheive: I have a report that i need to run using a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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...

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.