Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / May 2008

Tip: Looking for answers? Try searching our database.

Urgent - Create column on query depending on another column text

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Fred - 22 May 2008 15:37 GMT
HI.. i need help on solving one big problem i can't get the solution..
I have a query that gets some values and also a month text from one table..
based on a form parameters.. What i want to do is to add/create a column on
the query and make that column depend on the text of another column..
Like..if the text in colum month is "january" the value should be on column
"num" should be 1, "february" - 2, December - 12....etc

the SQL code i have before creating that column i need is:

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]));

Now i want to create column called "num" and i want to programme it
something like this code(in VBA only to exemplify):

if (query).(column_month).text = "January" then
(column_num).value = 1
else
if (query).(column_month).text = "February" then
(column_num).value = 2
else
if (query).(column_month).text = "March" then
(column_num).value = 3
else
..............................

Please help on how to do it..
Thanks!
Nuno
Jerry Whittle - 22 May 2008 19:25 GMT
Two choices.

Create a Months table with the names of the months in one column and the
number in another. Join this table in the query.

Another is to use something like below to create a date and use the Month
function on it. The year really doesn't matter.
 TheMonth: Month([Table1].[Month] & " 1, 2000")

Better yet if you already have a good date field in the table, use the Month
function on it.
Signature

Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

> HI.. i need help on solving one big problem i can't get the solution..
> I have a query that gets some values and also a month text from one table..
[quoted text clipped - 29 lines]
> Thanks!
> Nuno
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.