This question is directly related to this thread: http://www.access-programmers.co.uk/forums/showthread.php?t=174814
I am trying to figure out how to code in a query so that I can apply one of two numbers to a record based on it's seasonal value (which is determined by the month given for each record.)
There are 3 important fields that tie into this.
Jobtype- Some jobs have their own code associated with them, while others (the ones I'm working with) have a code based on summer or winter work.
Month- This is important in determining the seasonal code when applicable.
GL Number (or job code)- This is the field that I need to have the code associated with and be able to insert the proper value into.
This is the current code I have tried in SQL, I know there are problems with it, but I am unsure of what they are. Help is appreciated.
SELECT tblTruckValues.Truck, tblTruckValues.Jobtype, tblTruckValues.JobHour, tblTruckValues.fldYear, tblTruckValues.fldMonth, tblGlnumber.[GL Number] Or Iff(IsNull(tblGlnumber.[Gl Number]) THEN
If [tblmonnfthio.fldMonth = 12 OR tblmonthinfo.fldMonth < 3 THEN
[GL NUMBER] = "Winter Code2"
Else [GL Number] = "Summer Code1"
End If End If), [JobCost]*[JobHour] AS PRICE
FROM (tblGlnumber INNER JOIN (tblTruckValues INNER JOIN tblmonthinfo ON tblTruckValues.fldMonth = tblmonthinfo.fldMonth) ON tblGlnumber.[Job Type] = tblTruckValues.Jobtype) INNER JOIN tblCost ON tblTruckValues.Truck = tblCost.Truck;
I am trying to figure out how to code in a query so that I can apply one of two numbers to a record based on it's seasonal value (which is determined by the month given for each record.)
There are 3 important fields that tie into this.
Jobtype- Some jobs have their own code associated with them, while others (the ones I'm working with) have a code based on summer or winter work.
Month- This is important in determining the seasonal code when applicable.
GL Number (or job code)- This is the field that I need to have the code associated with and be able to insert the proper value into.
This is the current code I have tried in SQL, I know there are problems with it, but I am unsure of what they are. Help is appreciated.
SELECT tblTruckValues.Truck, tblTruckValues.Jobtype, tblTruckValues.JobHour, tblTruckValues.fldYear, tblTruckValues.fldMonth, tblGlnumber.[GL Number] Or Iff(IsNull(tblGlnumber.[Gl Number]) THEN
If [tblmonnfthio.fldMonth = 12 OR tblmonthinfo.fldMonth < 3 THEN
[GL NUMBER] = "Winter Code2"
Else [GL Number] = "Summer Code1"
End If End If), [JobCost]*[JobHour] AS PRICE
FROM (tblGlnumber INNER JOIN (tblTruckValues INNER JOIN tblmonthinfo ON tblTruckValues.fldMonth = tblmonthinfo.fldMonth) ON tblGlnumber.[Job Type] = tblTruckValues.Jobtype) INNER JOIN tblCost ON tblTruckValues.Truck = tblCost.Truck;