make query column values depend from another of it's columns

  • Thread starter Combo box type - help
  • Start date
C

Combo box type - help

Hi.. I need some help on how to do this.. I have a query that gives me back
some values an also the month... so i have 4 columns, 3 with values and one
with month like "january", "march".... Because i need to organize the query
by month what i'm trying to do is to activate manually another column (colum
"num") of that query and do something like this on the values criteria:
if "month"(column of the query) its january so "num" = 1
else if "month"(column of the query) its march so "num" = 3
and so on and so on..
I dont know where i define the values criteria and how to define them, in
terms of code and programming..
Please help..
Many thanks
Nuno
 
W

Wayne-I-M

If you really don't have any dates that you could use somewhere then you
could create a small table call tblMonths (MonthNumber = Number, MonthName =
Text)and in your other tables you would need to insert the linking field
(MonthNumber) as well.

In your query it would look something like this

SELECT tblMonths.MonthNumber, tblMonths.MonthName,
tblSomeOtherTable.Somefields, tblSomeOtherTable.MonthNumber
FROM tblMonths INNER JOIN tblSomeOtherTable ON tblMonths.MonthNumber =
tblSomeOtherTable.MonthNumber;
 
F

Fred

Thanks for your help wayne but probably because i'm new at this i'm not
exactly getting the way to do it..
I'll try to explain myself as good as possible..
I have a table1 with some value columns and also a month column.. i make a
query where i get this values and month from that table concerning to the
year i choose as a query parameter.. i created a new table as you told me -
(MonthNumber => Number, MonthName => Text).. as i understood i need also to
create the column MonthNumber in table1.. i did it.. know i think i
understand i need to make relationship between both tables but in that part i
need your help.. do i need to go to the relationships menu? how do i connect
them..which field from which table to which field from the other table..?
Then i just need to add the code you gave me to sql menu? and how do i add
in that code the other values of table1 i want in the query?

sorry for the confusion..
Thanks
Nuno
 
F

Fred

This might help.. this is the code i have without adding the MonthNumber part
and without the connection between tables..
This is the wuery without the "trying to organize the months" part.. :)

SELECT Table1.Ano, Table1.Parque, Table1.[Potência Produzida],
Table1.[Irradiância média], Table1.Temperatura, Table1.[Nº de horas de sol],
Table1.Month, Table1.Tarifa
FROM Table1
WHERE (((Table1.Ano)=[Forms]![Form3].[combo6]) AND
((Table1.Parque)=[Forms]![Form3].[combo4]));


"Fred" escreveu:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top