Avatar of rebaldy1
rebaldy1
 asked on

Replacing conditions of an If /Elseif with database fields

I am probably just having a brain fart, but I cant seem to see this answer.

I have the following code that works fine:

If ((navmonth = 4 And dateCounter > 4) Or (navmonth = 5 And dateCounter < 12)) And (Calendar = "Turkey") Then
    'do something
   
ElseIf ((navmonth = 9 And dateCounter > 26) Or (navmonth = 10 And dateCounter < 27) Or (navmonth = 11 And dateCounter >= 1) Or (navmonth = 1 And dateCounter < 5) Or (navmonth = 12)) And (Calendar = "Whitetail Archery") Then

    'do something else
Else
    'do default
   
End If

However, as you can see the conditions are hard coded.  I need this app to be dynamic, fed by a database.  I have set up a database and would like to sub the condtions of the If/elseIf for the values in the recordset.  I will need to loop through the records to see if the conditions will be true for each record.  Basically this populates an ASP Calendar.  I have the following code that works if I only have one record in the database:

dateSelect = navmonth & "/" & dateCounter & "/" & navyear
CalDate = cdate(dateSelect)

If (CalDate >= RSSeason("DateOpen") And CalDate <= RSSeason("DateClosed")) And (Calendar = RSSeason("Game")) Then
    'do something
   
Else
    'do default
   
End If

But if I use a Loop, I get multiple days(on the calendar) for each record in the table.  The only other ways I see scramble my conditional statements.  Any Ideas, its 5 in the morning and I am out of steam?

Thanks


Programming

Avatar of undefined
Last Comment
FaithRaven

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
gament

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
FaithRaven

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept gament's comment
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

FaithRaven
EE Cleanup Volunteer
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy