F
Florida Analyst
I'm not the best with SQL for Access however I want to create an IF THEN
Scenario, this is how I would write it in the SQL I know (I mostly use SAS):
(CASE WHEN [Age] is between 1 and 4 then "1 through 4"
WHEN [Age] is between 5 and 9 then "5 through 9"
WHEN [Age] is between 10 and 14 then "10 through 14"
ELSE "Not Important"
END) as [Age Category]
I tried to use Visual Basic and I created a SELECT CASE, however I believe
this can only be used in a form (I'm probably wrong) and all I need is a
query with this column added to it. Just in case I can use it here is the
code:
Public Function agecate(strSize As String) As String
Select Case strSize
Case 1 To 4
agecate = "1-4"
Case 5 To 9
agecate = "5-9"
Case 10 To 14
agecate = "10-14"
Case Else
agecate = "Don't Know"
End Select
End Function
Scenario, this is how I would write it in the SQL I know (I mostly use SAS):
(CASE WHEN [Age] is between 1 and 4 then "1 through 4"
WHEN [Age] is between 5 and 9 then "5 through 9"
WHEN [Age] is between 10 and 14 then "10 through 14"
ELSE "Not Important"
END) as [Age Category]
I tried to use Visual Basic and I created a SELECT CASE, however I believe
this can only be used in a form (I'm probably wrong) and all I need is a
query with this column added to it. Just in case I can use it here is the
code:
Public Function agecate(strSize As String) As String
Select Case strSize
Case 1 To 4
agecate = "1-4"
Case 5 To 9
agecate = "5-9"
Case 10 To 14
agecate = "10-14"
Case Else
agecate = "Don't Know"
End Select
End Function