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

Newbie looking for SQL update query help

Status
Not open for further replies.

surayo

Technical User
Jan 4, 2006
1
US
Hi,
I'm very new at this, so many apologies if this is really simple!

I'm trying to develop an update query that will add the results of two fields into a third field, only if that third field is blank.

For example: Field1 = Month, Field2=Spring/Summer, Field3=Fall/Winter. If there is NO numeric value in the month field, I want to add the results of Field2 and Field3 together, divide by 12, and have the result put into Field1.

I was thinking something like: if (month) is not null, then (month). Else, ((Spring/Summer + Fall/Winter)/12).

Anyone have a good idea of how to convert that statement above into acceptable SQL language? THANK you THANK you!!
 
Greetings.

Why not have field1=month (integer) on a form then figure the rest out. You might have the onChange event of a text box on a form be something like:

if me.field1 < 7 then 'if month is less than 7, the month has to be Jan through Jun
me.field2_txt = soemthing
else
me.field3_txt = something else
end if

Hope this gets you closer to the solution

Andrew
a.k.a. Dark Helmet

"What's the matter Colonel Sandurz? Chicken?
 
Something like this (SQL code) ?
UPDATE yourTable
SET [Month] = ([Spring/Summer] + [Fall/Winter]) / 12
WHERE [Month] Is Null

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top