Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query multiple columns, but only show chosen columns by year and month

Status
Not open for further replies.

piper3d

Technical User
Aug 8, 2002
6
US
The query I am trying to make is as follows.

I have data in columns, each column is a month and one is the year.
See example below.

Year Jan Feb March Apr May Jun Jul Aug Sep Oct Nov Dec

I have now when making this query to select the year, I put in the
parameters as [Enter Year] and when I run it, a window will pop up and
aske me to put in the year, I type in the year and it displays that
year and all of the data for each month.

I want to refine it. I want to enter the year and the month.

So when I run the query, I want to see only the year from the year
column and only the month I choose, I want to be able to type in the
month as I did as the year.

An example of how I want the query to run is this

Enter year, I type 2000 for the year.
Enter month, I type Feb because I only want to view Feb of the year
2000.

I want it to display the columns as follows,

Year Feb

Any help will be greatly appreciated.

Thank You In Advance,
Brian Weber
bweber@weberyoung.com
 
Is this a crosstab query?
If yes, is it based on a table or on a select query?
If based on a table, change it and base it on a query with a statement like:

PARAMETERS Mth Short, Yr Short;
SELECT *
FROM YourTable
WHERE (((Month([YourDateField]))=[mth]) AND ((Year([YourdateField]))=[yr]));

If it is based on a select query, define the parameters:
Query design view
Query->Parameters
Mth - Integer
Yr - Integer

Add the above Where clause to the query's SQL.
Now you'll be ready to run your crosstab.

If it's a select query from the beginning, I think your table design needs some refining...

HTH

Dan
[pipe]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top