I use a field ApplicationOrder to sort the records in my database. ApplicationOrder is numeric and I want to sort and name the ApplicationOrder and save the name as TimingLabel in a query.
I am stepping into new ground but have created the following function
and then my query is
but when I run the query ShortTimingComment is empty.
As said earlier this is new to me and had there not been so many "cases" I would have gone with a massive IIF statement but does anyone have any suggestions or observations as to what I have done wrong?
Thank you in advance for any suggestions.
I am stepping into new ground but have created the following function
Code:
Public Function CreateTimingLabel(ApplicationOrder As Double) As String
Select Case ApplicationOrder
Case Is < 0.9
ShortTimingComment = "Sept/Oct"
Case Is < 1.9
ShortTimingComment = "Jan"
Case Is < 2.29
ShortTimingComment = "E Feb"
Case Is < 2.69
ShortTimingComment = "Feb"
Case Is < 2.99
ShortTimingComment = "L Feb"
Case Is < 3.29
ShortTimingComment = "E Mar"
Case Is < 3.69
ShortTimingComment = "Mar"
Case Is < 3.99
ShortTimingComment = "L Mar"
Case Is < 4.29
ShortTimingComment = "E Apr"
Case Is < 4.69
ShortTimingComment = "Apr"
Case Is < 4.99
ShortTimingComment = "L Apr"
Case Is < 5.29
ShortTimingComment = "E May"
Case Is < 5.69
ShortTimingComment = "May"
Case Is < 5.99
ShortTimingComment = "L May"
Case Is < 6.99
ShortTimingComment = "June"
Case Is < 7.99
ShortTimingComment = "July"
Case Is < 8.99
ShortTimingComment = "Aug"
Case Else 'this means the case is something unexpected
ShortTimingComment = "Unspec"
End Select
End Function
and then my query is
Code:
SELECT qrySLTReport.CroppingYear, qrySLTReport.AccountName, tblFieldDetails.FieldName, tblVariety.Variety, Round(([NContent]*[ApplicationRate])/1000) AS NApplied, tblFertApplns.ApplicationIndex, tblFertApplns.ApplicationOrder, CreateTimingLabel([ApplicationOrder]) AS ShortTimingComment
FROM tblFertProduct INNER JOIN (((qrySLTReport INNER JOIN tblFieldDetails ON qrySLTReport.FarmAccountNumber = tblFieldDetails.FarmAccountNumber) INNER JOIN (tblCropping INNER JOIN tblVariety ON tblCropping.VarietyID = tblVariety.VarietyID) ON (tblFieldDetails.FieldCode = tblCropping.FieldCode) AND (qrySLTReport.CroppingYear = tblCropping.CroppingYear)) INNER JOIN (tblApplnTimings INNER JOIN tblFertApplns ON tblApplnTimings.TimingCode = tblFertApplns.TimingCode) ON tblCropping.CroppingNumber = tblFertApplns.CroppingNumber) ON tblFertProduct.ProductIndex = tblFertApplns.ProductIndex
WHERE (((Round(([NContent]*[ApplicationRate])/1000))>0))
ORDER BY tblFieldDetails.FieldName;
but when I run the query ShortTimingComment is empty.
As said earlier this is new to me and had there not been so many "cases" I would have gone with a massive IIF statement but does anyone have any suggestions or observations as to what I have done wrong?
Thank you in advance for any suggestions.