MajP
You've got your good things, and you've got mine.
- Local time
- Today, 18:43
- Joined
- May 21, 2018
- Messages
- 9,493
As previously stated the way it currently works
1. is that it sorts each list of messages randomly.
2. It counts how many messages are available (in this case 250 for work, love, and finance).
3. For each day you need 12 groups of three messages so it divides 250\12 to get 20 days that you can write.
4. It reads each list from top to bottom giving the first 20 messages for to the first zodiac, then resets the date and gives 20 messages to the next zodiac.
So this gets a little confusing and I will have to post a new DB. But to avoid when writing day 21 that you do not reuse a message from day 12 - 20 I first determine if a message was used in the last 9 days. (12 messages per day * 9 days = 108)
qryLast9
in the old qryRandomWork, qryRandomLove, qryRandomFinance I simply sorted by my random function. Now I want to sort first by if it was not in the last 9 days then by a random number. Unfortunately I could not get it to sort without an error so I did it in two parts.
new qryRandomWork
if it was used in the last 9 days the field would return a 1.
Now (since I am not smart enough to do all the above in a single query) I sort it by if it was previously used and by the random number
qryRandomWorkSorted
Then do that for love, and finance and use the new queries in the code
the above will ensure you can do 20 days at a time or (Number of messages \ 12) without any repetition, and there will not be repetition within 9 days from the last group of 20 messages.
Although I added these two extra queries there is probably a way to do it in a subquery.
1. is that it sorts each list of messages randomly.
2. It counts how many messages are available (in this case 250 for work, love, and finance).
3. For each day you need 12 groups of three messages so it divides 250\12 to get 20 days that you can write.
4. It reads each list from top to bottom giving the first 20 messages for to the first zodiac, then resets the date and gives 20 messages to the next zodiac.
So this gets a little confusing and I will have to post a new DB. But to avoid when writing day 21 that you do not reuse a message from day 12 - 20 I first determine if a message was used in the last 9 days. (12 messages per day * 9 days = 108)
qryLast9
Code:
SELECT TOP 108
tblHoroscope.LoveID_FK,
tblHoroscope.FinanceID_FK,
tblHoroscope.WorkID_FK,
tblHoroscope.HoroscopeDate
FROM
tblHoroscope
ORDER BY
tblHoroscope.HoroscopeDate DESC;
in the old qryRandomWork, qryRandomLove, qryRandomFinance I simply sorted by my random function. Now I want to sort first by if it was not in the last 9 days then by a random number. Unfortunately I could not get it to sort without an error so I did it in two parts.
new qryRandomWork
Code:
SELECT
Work.WorkID,
Work.Discription_Work,
(Select count(*) from qryLast9 where qryLast9.WorkID_FK = Work.WorkID) AS CountInLast9,
MajP_Rnd([workid]) AS Sort
FROM
[Work]
ORDER BY
MajP_Rnd([workid]);
Now (since I am not smart enough to do all the above in a single query) I sort it by if it was previously used and by the random number
qryRandomWorkSorted
Code:
SELECT
qryRandomWork.WorkID,
qryRandomWork.CountInLast9,
qryRandomWork.Sort
FROM
qryRandomWork
ORDER BY
qryRandomWork.CountInLast9,
qryRandomWork.Sort;
Then do that for love, and finance and use the new queries in the code
Code:
Set rsWork = CurrentDb.OpenRecordset("qryRandomWOrksorted")
Set rsLove = CurrentDb.OpenRecordset("qryRandomLovesorted")
Set rsFinance = CurrentDb.OpenRecordset("qryRandomFinancesorted")
the above will ensure you can do 20 days at a time or (Number of messages \ 12) without any repetition, and there will not be repetition within 9 days from the last group of 20 messages.
Although I added these two extra queries there is probably a way to do it in a subquery.