Hello All,
I am in a dilemma. I have written this long CASE statement to work in VB for a specific Task.
I have searched and searched everywhere. I am getting a lot of mixed responses, however, one that seems to be common is that I am unable to use CASE statement in Access VBA.
Anyways, below is the CASE Statement. If all the statements are run Individually, as update statements, they run perfectly fine. However, I have around 50 of these conditional stmts and I need to speed up the performance of this Update query.
Any help or ideas are much appreciated.
Here is the code:
strSQL1 = "UPDATE ATBTemp SET Aging = " & _
“CASE “ & _
"WHEN [Age 2] < 31 THEN '0-30'" & _
"WHEN [Age 2] between 31 and 60 THEN '31-60'" & _
"WHEN [Age 2] between 61 and 90 THEN '61-90'" & _
"WHEN [Age 2] between 91 and 120 THEN '91-120'" & _
"WHEN [Age 2] between 121 and 150 THEN '121-150'" & _
"WHEN [Age 2] between 151 and 180 THEN '151-180'" & _
"WHEN [Age 2] between 181 and 210 THEN '181-210'" & _
"WHEN [Age 2] between 211 and 240 THEN '211-240'" & _
"WHEN [Age 2] > 240 THEN '> 240'" & _
“END”
I have 3 of such case statements, with the other 2 combining for over 55 WHEN stmts.
Thanks in Advance.
I am in a dilemma. I have written this long CASE statement to work in VB for a specific Task.
I have searched and searched everywhere. I am getting a lot of mixed responses, however, one that seems to be common is that I am unable to use CASE statement in Access VBA.
Anyways, below is the CASE Statement. If all the statements are run Individually, as update statements, they run perfectly fine. However, I have around 50 of these conditional stmts and I need to speed up the performance of this Update query.
Any help or ideas are much appreciated.
Here is the code:
strSQL1 = "UPDATE ATBTemp SET Aging = " & _
“CASE “ & _
"WHEN [Age 2] < 31 THEN '0-30'" & _
"WHEN [Age 2] between 31 and 60 THEN '31-60'" & _
"WHEN [Age 2] between 61 and 90 THEN '61-90'" & _
"WHEN [Age 2] between 91 and 120 THEN '91-120'" & _
"WHEN [Age 2] between 121 and 150 THEN '121-150'" & _
"WHEN [Age 2] between 151 and 180 THEN '151-180'" & _
"WHEN [Age 2] between 181 and 210 THEN '181-210'" & _
"WHEN [Age 2] between 211 and 240 THEN '211-240'" & _
"WHEN [Age 2] > 240 THEN '> 240'" & _
“END”
I have 3 of such case statements, with the other 2 combining for over 55 WHEN stmts.
Thanks in Advance.