al4629740
asked on
Loop months of the year in this code
I am trying to loop 3 months of the year into the code below. How do I write this type of loop statement. I am drawing a blank for some reason...
'How turn this into a loop where Var1 is a loop of January, February, March so that I get the total for all 3 months
select count(*) from table where Month = Var1
rec2.CursorLocation = adUseClient
rec2.Open (esql), conn, adOpenStatic, adLockOptimistic
Total = Total + rec.Fields(0)
ASKER
Month column is text.
What I need was a loop to go through specified months as mentioned in the question.
Thanks
What I need was a loop to go through specified months as mentioned in the question.
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
select count(*)
from table
where Month = 'January'
or Month = 'February'
or Month = ' March'
from table
where Month = 'January'
or Month = 'February'
or Month = ' March'
No loop required, just the query
ASKER
Thanks for the effort
What type of column is "month" (numeric or text)?
Normally, I would create a Select statement that summed/counted the data for a date range, rather than executing three different Select statements.
Example:
Open in new window