Hi all,
This is my continuation of previous thread. I figured this could be it's own thread since it's a follow-up question.
I would like to use date value returned in my code and check if the month of that date is also present in another recordset which I use to activate/deactivate certain months. If the month matches activated month then code can proceed, if not, then it needs to run rest of my code again to find another month which is activated.
With this code below:
------------------------------------------------------------------
This line of code takes my date field and checks if it falls on a month/year which has less than 3 items assigned to it.
If it doesn't, it subtracts a month and checks again:
Now, I have a recordset
So I want in incorporate this variable in code above.
I don't know where to intersect the code, and which method to use...
Do I use an array?
How do I compare to see if value of my date checks if month is in the recordset?
Do I put it all in a loop, if so in which part of the code?
Do I use something like:
Any help, or at least direction would be appreciated!
This is my continuation of previous thread. I figured this could be it's own thread since it's a follow-up question.
I would like to use date value returned in my code and check if the month of that date is also present in another recordset which I use to activate/deactivate certain months. If the month matches activated month then code can proceed, if not, then it needs to run rest of my code again to find another month which is activated.
With this code below:
Code:
Do While Not rstLP.EOF
rstLP.Edit
nxtinspection = rstLP!fldIQADue
Do Until DCount("fldIQA", "tblWIUnion", "Format$(fldIQA,'yyyymm')='" & Format$(nxtinspection, "yyyymm") & "'") < 3
nxtinspection = DateAdd("m", -1, nxtinspection)
Loop
rstLP!fldIQA = nxtinspection
rstLP.Update
rstLP.MoveNext
Loop
rstLP.Close
Set rstLP = Nothing
This line of code takes my date field and checks if it falls on a month/year which has less than 3 items assigned to it.
Do Until DCount("fldIQA", "tblWIUnion", "Format$(fldIQA,'yyyymm')='" & Format$(nxtinspection, "yyyymm") & "'") < 3
If it doesn't, it subtracts a month and checks again:
nxtinspection = DateAdd("m", -1, nxtinspection)
Now, I have a recordset
rstMonth
with SQL string which stores all month names that also have a checkmark next to them. To help visualize, I have included the following picture:So I want in incorporate this variable in code above.
I don't know where to intersect the code, and which method to use...
Do I use an array?
How do I compare to see if value of my date checks if month is in the recordset?
Do I put it all in a loop, if so in which part of the code?
Do I use something like:
Format(rstMonth.Fields("fldMonth"), "mmmm")
to compare?Any help, or at least direction would be appreciated!