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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access issues

Status
Not open for further replies.

Marvin88

MIS
Jul 2, 2003
10
0
0
US
Two things, Is there a way to dynamically pick the column you want to puu information from via the query? I want to pull a sumation of budget information for the current month. Each month's budget is kept in it's own column (i.e. budget1, budget2...budget12). I want to have a select stmnt that looks at the current month and appends it to "budget" so the select stmnt only pull information for the correct budget month.

Any ideas?
(select "budget" & month(now) returns "budget7" for every record.

I'll deal with the other in another thread.
 
i have the same kind of thing going on.
first i make a UNION query to put all of the data in a usable format. in my case, later i filter on date ranges, so i make each 'month' be the first of each month:
YEAR JAN FEB MAR APR MAY blah
2003 185 855 186 255 355 etc

i translate to:

1/1/03 185
2/1/03 855
3/1/03 186
4/1/03 255

etc

then the query is in a usable format.

so for you, depending on how you want the end product to look, you could do this:
Code:
SELECT "Jan" AS [Month], BudgetTable.Budget1
FROM BudgetTable UNION
SELECT "Feb" AS [Month], BudgetTable.Budget2
FROM BudgetTable UNION
SELECT "Mar" AS [Month], BudgetTable.Budget3
FROM BudgetTable;

just keep adding on for each month after you like the output. what i do is first make a simple select query, once i like what it is with just the first column in the results, i choose in query design VIEW SQL, add "UNION" and copy, paste and tweek each successive piece of code. for the above, you'll get:

JAN 188
FEB 233
MAR 888

or whatever. you can label it as you wish.

see if you can move along with this help. then later on your queries, and such, you will just filter on the month, or date, or whatever you label them as.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top