How it Work function Rnd()? (1 Viewer)

MajP

You've got your good things, and you've got mine.
Local time
Today, 06:48
Joined
May 21, 2018
Messages
8,605
Shifts the signs and does not arrange them as they are one after the other ... Can this be fine? I attached a picture.

1. In report design go to "Sorting and Grouping" . If you do not know how to do this, then Google it. Currently it is Grouped by
Code:
HoroscopeDate
  Zodiac

This means the Zodiac is sorted alphabetically. Change it to
Code:
HoroscopeDate
[B]  ZodiacID[/B]

Will this entire shuffle work for every date on the calendar as you did it from 21.04.2019 to 12.11.2019. That's 205 days. I add 205 text for each category. Will it mix them everyday to be a different text without repetition for all the days?
2. The code is designed to write as random messages without repetition for as many text messages that exist. If you have 250 it will write 250, if you have 1000 it will create 1000.

3. If you move beyond the number of messages it will create messages.
Move to last message. Click the up arrow to write messages.


1. В дизайна на отчета отидете на "Сортиране и групиране". Ако не знаете как да направите това, а след това го Google. Понастоящем е групирана по
Code:
HoroscopeDate
  Zodiac

Това означава, че Зодиакът е сортиран по азбучен ред. Променете го на
Code:
HoroscopeDate
[B]  ZodiacID[/B]


2. Кодът е предназначен да записва като случайни съобщения без повторение за толкова текстови съобщения, които съществуват. Ако имате 250 ще напише 250, ако имате 1000 ще създаде 1000.

3. Ако преминете броя на съобщенията, ще създадете съобщения.
Преместване към последното съобщение. Кликнете върху стрелката нагоре, за да пишете съобщения.

1. V dizaĭna na otcheta otidete na "Sortirane i grupirane". Ako ne znaete kak da napravite tova, a sled tova go Google. Ponastoyashtem e grupirana po
Code:
HoroscopeDate
  Zodiac

Tova oznachava, che Zodiakŭt e sortiran po azbuchen red. Promenete go na
Code:
HoroscopeDate
[B]  ZodiacID[/B]


2. Kodŭt e prednaznachen da zapisva kato sluchaĭni sŭobshteniya bez povtorenie za tolkova tekstovi sŭobshteniya, koito sŭshtestvuvat. Ako imate 250 shte napishe 250, ako imate 1000 shte sŭzdade 1000.

3. Ako preminete broya na sŭobshteniyata, shte sŭzdadete sŭobshteniya.
Premestvane kŭm poslednoto sŭobshtenie. Kliknete vŭrkhu strelkata nagore, za da pishete sŭobshteniya
 

KrIs86BsBG

Registered User.
Local time
Today, 13:48
Joined
Apr 21, 2019
Messages
34
1. In report design go to "Sorting and Grouping" . If you do not know how to do this, then Google it. Currently it is Grouped by
Code:
HoroscopeDate
  Zodiac

This means the Zodiac is sorted alphabetically. Change it to
Code:
HoroscopeDate
[B]  ZodiacID[/B]

I do not have this menu "Sorting and Grouping" and does not allow me to add it :(
 

Attachments

  • Form145.jpg
    Form145.jpg
    98.7 KB · Views: 113

jdraw

Super Moderator
Staff member
Local time
Today, 06:48
Joined
Jan 23, 2006
Messages
15,393
As MajP suggested

In report design go to "Sorting and Grouping" . If you do not know how to do this, then Google it.
Good luck.
 

KrIs86BsBG

Registered User.
Local time
Today, 13:48
Joined
Apr 21, 2019
Messages
34
This means the Zodiac is sorted alphabetically. Change it to
Code:
HoroscopeDate
[B]  ZodiacID[/B]

1. I fixed it. But now I have another question that is important ... I choose to make a horoscope for me on 03.05.2019 and it shows me the same texts in the different signs ... but I have 205 texts for each category ... why the shuffle does not work ?
2. I think the problem comes from a table: qryHoroscope because it mixes different ID only up to 30, and they are 205 texts ...
3. How do I make the report font bigger: For example, 15 points?

1. Оправих го. Но сега имам друг въпрос, който е важен... Избирам си да ми направи хороскоп за 03.05.2019 и ми показва едни и същи текстове в различните зодии...а имам по 205 текста за всяка категория...защо не работи разбъркването?
2. Смятам, че проблема идва от таблица: qryHoroscope, защото там разбърква различните ИД само до 30, а те са 205 текста...
3. Как да направя шрифта на отчета да е по-голям: Например 15 пункта?
 

Attachments

  • Repeat Text.jpg
    Repeat Text.jpg
    70.3 KB · Views: 110
Last edited:

jdraw

Super Moderator
Staff member
Local time
Today, 06:48
Joined
Jan 23, 2006
Messages
15,393
Your picture was for a Form. You need Report Design view.
Reports have Sorting and Grouping option.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 06:48
Joined
May 21, 2018
Messages
8,605
1. I fixed it. But now I have another question that is important ... I choose to make a horoscope for me on 03.05.2019 and it shows me the same texts in the different signs ... but I have 205 texts for each category ... why the shuffle does not work ?
It is possible to get the same messages for two Signs, but what you show is very unlikely. Currently the code writes as many days as there are messages (250). It is no longer 30 if you are using the updated code. Make sure your code is

Code:
Public Sub CreateHoroscope2(TheDate As Date)
  'Creates 30 days out of horoscope without repitition
  
  Dim strSql As String
  Dim rszodiac As DAO.Recordset
  Dim rsLove As DAO.Recordset
  Dim rsWork As DAO.Recordset
  Dim rsFinance As DAO.Recordset
  Dim i As Integer
  Dim LoveID As Long
  Dim WorkID As Long
  Dim ZodiacID As Long
  Dim FinanceID As Long
  Dim HoroscopeDate As String
  Dim NewDate As Date
  Dim maxMessages As Integer
  NewDate = TheDate
  
  Set rszodiac = CurrentDb.OpenRecordset("Select ZodiacID from Zodiac")
  maxMessages = DCount("*", "Love")
  If DCount("*", "Finance") < maxMessages Then maxMessages = DCount("*", "Finance")
  If DCount("*", "Work") < maxMessages Then maxMessages = DCount("*", "Work")
  Do While Not rszodiac.EOF ' do each zodiac
     Set rsWork = CurrentDb.OpenRecordset("qryRandomWOrk")
     Set rsLove = CurrentDb.OpenRecordset("qryRandomLove")
     Set rsFinance = CurrentDb.OpenRecordset("qryRandomFinance")
     ZodiacID = rszodiac!ZodiacID
    For i = 1 To maxMessages ' each available message
        HoroscopeDate = BulgarianDate(TheDate)
        LoveID = rsLove!LoveID
        WorkID = rsWork!WorkID
        FinanceID = rsFinance!FinanceID
        strSql = "Insert Into tblHoroscope (HoroscopeDate, ZodiacID_FK, LoveID_FK, WorkID_FK, FinanceID_FK) "
        strSql = strSql & "values (" & HoroscopeDate & ", " & ZodiacID & ", " & LoveID & ", " & WorkID & ", " & FinanceID & ")"
    Debug.Print strSql
        rsWork.MoveNext
        rsLove.MoveNext
        rsFinance.MoveNext
        CurrentDb.Execute strSql
        NewDate = NewDate + 1
    Next i
    NewDate = TheDate
    rszodiac.MoveNext
  Loop
End Sub

The way it currently works it gets your 250 random sets for a sign and writes those. Then it gets 250 for the next sign. It is possible, but unlikely two signs get the same messages on the same date. The assumption was that it was important to get a lot of days for a given sign without repeat, and not concerned about repeats between sign.

The code could get modified if necessary to ensure for a given date there are no repeat messages.



2. I think the problem comes from a table: qryHoroscope because it mixes different ID only up to 30, and they are 205 texts ...
That is not correct as explained.

3. How do I make the report font bigger: For example, 15 points?
I am sure in Bulgaria they have the internet and even Google. You need to learn how to use these for basic questions. I can fix my car, my appliance, my house for things I have never done. Just google and there is a person with a video or detailed explanation. I post tens of thousands of posts on Access and only ever ask a handful of questions. Not because I am smart, but because I only asks questions after doing a lot of research on my own.
 

Gasman

Enthusiastic Amateur
Local time
Today, 11:48
Joined
Sep 21, 2011
Messages
14,465
FWIW I can confirm one can get duplicates, but it is random after all?

See Love entries between Cancer and Capricorn, also Work entries between Capricorn and Gemini.

Not that I believe in all this stuff, but what is to say an entry cannot apply to more than one horoscope sign.?
 

Attachments

  • RptHoroscope1.docx
    17.8 KB · Views: 105

KrIs86BsBG

Registered User.
Local time
Today, 13:48
Joined
Apr 21, 2019
Messages
34
FWIW I can confirm one can get duplicates, but it is random after all?

See Love entries between Cancer and Capricorn, also Work entries between Capricorn and Gemini.

Not that I believe in all this stuff, but what is to say an entry cannot apply to more than one horoscope sign.?


If you have many texts in the daily horoscope, there is no repeatability for any sign. Even in this document, where there are 90 texts common to all categories there is a repetition of the texts in the different signs:

Code:
Aries -->Sagittarius; Cancer -->Capricorn; Gemini --> Virgo - [B]Love[/B] Repeat;
Aquarius --> Taurus; Capricorn --> Gemini - [B]Work[/B] Repeat;
Aries -->Libra; Cancer -->Leo - [B]Finance[/B] Repeat
 

KrIs86BsBG

Registered User.
Local time
Today, 13:48
Joined
Apr 21, 2019
Messages
34
Code:
Public Sub CreateHoroscope2(TheDate As Date)
  'Creates 30 days out of horoscope without repitition
  
  Dim strSql As String
  Dim rszodiac As DAO.Recordset
  Dim rsLove As DAO.Recordset
  Dim rsWork As DAO.Recordset
  Dim rsFinance As DAO.Recordset
  Dim i As Integer
  Dim LoveID As Long
  Dim WorkID As Long
  Dim ZodiacID As Long
  Dim FinanceID As Long
  Dim HoroscopeDate As String
  Dim NewDate As Date
  Dim maxMessages As Integer
  NewDate = TheDate
  
  Set rszodiac = CurrentDb.OpenRecordset("Select ZodiacID from Zodiac")
  maxMessages = DCount("*", "Love")
  If DCount("*", "Finance") < maxMessages Then maxMessages = DCount("*", "Finance")
  If DCount("*", "Work") < maxMessages Then maxMessages = DCount("*", "Work")
  Do While Not rszodiac.EOF ' do each zodiac
     Set rsWork = CurrentDb.OpenRecordset("qryRandomWOrk")
     Set rsLove = CurrentDb.OpenRecordset("qryRandomLove")
     Set rsFinance = CurrentDb.OpenRecordset("qryRandomFinance")
     ZodiacID = rszodiac!ZodiacID
    For i = 1 To maxMessages ' each available message
        HoroscopeDate = BulgarianDate(TheDate)
        LoveID = rsLove!LoveID
        WorkID = rsWork!WorkID
        FinanceID = rsFinance!FinanceID
        strSql = "Insert Into tblHoroscope (HoroscopeDate, ZodiacID_FK, LoveID_FK, WorkID_FK, FinanceID_FK) "
        strSql = strSql & "values (" & HoroscopeDate & ", " & ZodiacID & ", " & LoveID & ", " & WorkID & ", " & FinanceID & ")"
    Debug.Print strSql
        rsWork.MoveNext
        rsLove.MoveNext
        rsFinance.MoveNext
        CurrentDb.Execute strSql
        NewDate = NewDate + 1
    Next i
    NewDate = TheDate
    rszodiac.MoveNext
  Loop
End Sub

1. The code is correct and I tested for a new horoscope from today and again repeats the same text from one sign and one category in another sign of the same category, but different combinations should be ... yet it has a database of 615 text for all categories Love, Work and Finance ... Can it be made every day to show different texts without repeating the signs? I think shuffling is not working properly ... Where should I change the code?

1. Кода е правилен и тествах за нов хороскоп от днес и отново повтаря един и същи текст от една зодия и една категория в друга зодия със същата категория, а би трябвало да са различни комбинациите...все пак разполага с база данни от 615 текста за всички категории Любов, Работа и Финанси... Може ли да се направи всеки ден да показва различни текстове без повтаряне по зодиите? Според мен размесването не функционира правилно...Къде трябва да променя кода?

2. The attached photo of a qryHoroscope request in the columns LoveID, WorkID and FinanceID the numbers are from 1 to 30, and this should not be correct because I already have 205 text for each category and therefore the new values should appear ... and this is not happening. . I believe that here comes the repetition. How can fix it to show the new values and mix them without repeating for each day on any text?

2. В прикачената снимка на заявка qryHoroscope в колоните LoveID, WorkID and FinanceID числата са от 1 до 30, а това не би трябвало да е правилно, защото вече имам по 205 текста за всяка категория и следователно трябва да се появят новите стойности...а това не става...Смятам, че оттук идва повтарянето. Как може да се оправи за да показва новите стойности и да ги разбърква без повтаряне за всеки ден на нито един текст?
 

Attachments

  • qryHoroscopeWrong.jpg
    qryHoroscopeWrong.jpg
    104.5 KB · Views: 117
Last edited:

MajP

You've got your good things, and you've got mine.
Local time
Today, 06:48
Joined
May 21, 2018
Messages
8,605
Replace CreateHoroscope2 with this code. This will ensure no repeats between horoscopes within a day. If you have 615 messages it will create 51 days with no repeat of any messages. This code produces few days at each run (615\12 days versus 615 days), but eliminates all repeats.

Code:
Public Sub CreateHoroscope2(TheDate As Date)
  'Creates 30 days out of horoscope without repitition
  
  Dim strSql As String
  Dim rszodiac As DAO.Recordset
  Dim rsLove As DAO.Recordset
  Dim rsWork As DAO.Recordset
  Dim rsFinance As DAO.Recordset
  Dim i As Integer
  Dim LoveID As Long
  Dim WorkID As Long
  Dim ZodiacID As Long
  Dim FinanceID As Long
  Dim HoroscopeDate As String
  Dim NewDate As Date
  Dim maxMessages As Integer
  NewDate = TheDate
  
  
  maxMessages = DCount("*", "Love")
  If DCount("*", "Finance") < maxMessages Then maxMessages = DCount("*", "Finance")
  If DCount("*", "Work") < maxMessages Then maxMessages = DCount("*", "Work")
  
  Set rsWork = CurrentDb.OpenRecordset("qryRandomWOrk")
  Set rsLove = CurrentDb.OpenRecordset("qryRandomLove")
  Set rsFinance = CurrentDb.OpenRecordset("qryRandomFinance")
  
  For i = 1 To maxMessages \ 12  'Example: if you have 610 messages you can do this for 50 days

    Set rszodiac = CurrentDb.OpenRecordset("Select ZodiacID from Zodiac")
    Do While Not rszodiac.EOF ' do each zodiac
        ZodiacID = rszodiac!ZodiacID
        HoroscopeDate = BulgarianDate(NewDate)
        LoveID = rsLove!LoveID
        WorkID = rsWork!WorkID
        FinanceID = rsFinance!FinanceID
        strSql = "Insert Into tblHoroscope (HoroscopeDate, ZodiacID_FK, LoveID_FK, WorkID_FK, FinanceID_FK) "
        strSql = strSql & "values (" & HoroscopeDate & ", " & ZodiacID & ", " & LoveID & ", " & WorkID & ", " & FinanceID & ")"
        Debug.Print strSql
        rsWork.MoveNext
        rsLove.MoveNext
        rsFinance.MoveNext
        rszodiac.MoveNext
        CurrentDb.Execute strSql
    Loop
   NewDate = NewDate + 1
  Next i
End Sub
 

KrIs86BsBG

Registered User.
Local time
Today, 13:48
Joined
Apr 21, 2019
Messages
34
Replace CreateHoroscope2 with this code. This will ensure no repeats between horoscopes within a day. If you have 615 messages it will create 51 days with no repeat of any messages. This code produces few days at each run (615\12 days versus 615 days), but eliminates all repeats.

Code:
Public Sub CreateHoroscope2(TheDate As Date)
  'Creates 30 days out of horoscope without repitition
  
  Dim strSql As String
  Dim rszodiac As DAO.Recordset
  Dim rsLove As DAO.Recordset
  Dim rsWork As DAO.Recordset
  Dim rsFinance As DAO.Recordset
  Dim i As Integer
  Dim LoveID As Long
  Dim WorkID As Long
  Dim ZodiacID As Long
  Dim FinanceID As Long
  Dim HoroscopeDate As String
  Dim NewDate As Date
  Dim maxMessages As Integer
  NewDate = TheDate
  
  
  maxMessages = DCount("*", "Love")
  If DCount("*", "Finance") < maxMessages Then maxMessages = DCount("*", "Finance")
  If DCount("*", "Work") < maxMessages Then maxMessages = DCount("*", "Work")
  
  Set rsWork = CurrentDb.OpenRecordset("qryRandomWOrk")
  Set rsLove = CurrentDb.OpenRecordset("qryRandomLove")
  Set rsFinance = CurrentDb.OpenRecordset("qryRandomFinance")
  
  For i = 1 To maxMessages \ 12  'Example: if you have 610 messages you can do this for 50 days

    Set rszodiac = CurrentDb.OpenRecordset("Select ZodiacID from Zodiac")
    Do While Not rszodiac.EOF ' do each zodiac
        ZodiacID = rszodiac!ZodiacID
        HoroscopeDate = BulgarianDate(NewDate)
        LoveID = rsLove!LoveID
        WorkID = rsWork!WorkID
        FinanceID = rsFinance!FinanceID
        strSql = "Insert Into tblHoroscope (HoroscopeDate, ZodiacID_FK, LoveID_FK, WorkID_FK, FinanceID_FK) "
        strSql = strSql & "values (" & HoroscopeDate & ", " & ZodiacID & ", " & LoveID & ", " & WorkID & ", " & FinanceID & ")"
        Debug.Print strSql
        rsWork.MoveNext
        rsLove.MoveNext
        rsFinance.MoveNext
        rszodiac.MoveNext
        CurrentDb.Execute strSql
    Loop
   NewDate = NewDate + 1
  Next i
End Sub

1. Благодаря. След като създадох нова дата в календара ми ги разменя без повтаряне. Това ще работи ли без ограничение за датите ?

1. Thanks. Once I created a new date on my calendar I exchanged them without repeating. Will this work without limits for the dates?
 
Last edited:

Gasman

Enthusiastic Amateur
Local time
Today, 11:48
Joined
Sep 21, 2011
Messages
14,465
You need to delete the records in the table tblHoroscope and start afresh.
They will have been created with the old version of the code.

MajP has done all this work for you, and you still do not know how it works.?:banghead:

How are you going to make amendments and add further functionality.?
 

KrIs86BsBG

Registered User.
Local time
Today, 13:48
Joined
Apr 21, 2019
Messages
34
You need to delete the records in the table tblHoroscope and start afresh.
They will have been created with the old version of the code.

MajP has done all this work for you, and you still do not know how it works.?:banghead:

How are you going to make amendments and add further functionality.?

1. I fixed it. I understand where the problem was. Thanks!

1. Оправих го. Разбрах къде е бил проблема. Благодаря!
 

KrIs86BsBG

Registered User.
Local time
Today, 13:48
Joined
Apr 21, 2019
Messages
34
Replace CreateHoroscope2 with this code. This will ensure no repeats between horoscopes within a day. If you have 615 messages it will create 51 days with no repeat of any messages. This code produces few days at each run (615\12 days versus 615 days), but eliminates all repeats.

1. Again, I have a problem. One text of one sign and category is repeated after 2 or 3 days in another zodiac and in the same category. Can not repeat any text for 9 days and only after 9 days pass from one sign to another?

2. Отново имам проблем. Един текст от една зодия и категория се повтаря след 2 или 3 дни в друга зодия и в същата категория. Може ли да не се повтаря нито един текст за 9 дни и чак след 9 ден да преминава от една зодия в друга?
 

Gasman

Enthusiastic Amateur
Local time
Today, 11:48
Joined
Sep 21, 2011
Messages
14,465
This the consequence on not learning anything yourself.
You have to keep coming back for more amendments. :(
 

KrIs86BsBG

Registered User.
Local time
Today, 13:48
Joined
Apr 21, 2019
Messages
34
1. Can anyone tell me where to make the changes in the code and exactly what to do, so there will be no repetition for 9 days and after the ninth day the texts will pass from one sign to another?

2. Някой може ли да ми каже къде в кода да направя промени и какви точно, за да няма повтаряне за 9 дни и след деветия ден текстовете да преминават от една зодия в друга?
 

Gasman

Enthusiastic Amateur
Local time
Today, 11:48
Joined
Sep 21, 2011
Messages
14,465
You need more texts
Each time the program starts it creates as many as it can.

Code:
For i = 1 To maxMessages \ 12  'Example: if you have 610 messages you can do this for 50 days

so I believe you need at least 108 texts in each table if you do not want to repeat for at least 9 days.?
 

KrIs86BsBG

Registered User.
Local time
Today, 13:48
Joined
Apr 21, 2019
Messages
34
You need more texts
Each time the program starts it creates as many as it can. So I believe you need at least 108 texts in each table if you do not want to repeat for at least 9 days.?

I have 205 texts for each category, but this texts repeat for 2 or 3 days in random zodiac...
 

Gasman

Enthusiastic Amateur
Local time
Today, 11:48
Joined
Sep 21, 2011
Messages
14,465
Personally if you used MajP's latest code I cannot see how that would happen.?
Upload the DB with the required texts and I'll try it out.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 06:48
Joined
May 21, 2018
Messages
8,605
Personally if you used MajP's latest code I cannot see how that would happen.?
Upload the DB with the required texts and I'll try it out.

I ran the code with 250 texts. It will produce 240 groups (20 days of messages for 12 zodiacs) of random messages with no repeats anywhere.

Now it gets complicated and this part has not yet been developed. Assume you want to create days 21 to 41. It will create another 20 days of messages with no repeats. However, you can have repeats between the last group and next group ( so messages 12 - 20 could have repeats with messages 21 - 29).

There are several ways to fix this. Since you always read the random sorted lists from top to bottom, first sort the list by if it has been used in the last nine days and then by the random number. This will push the previously last nine days to the bottom of the list where they will be sorted randomly but after the other messages not used in the last nine days. When I get a chance I will try to fix.
 

Users who are viewing this thread

Top Bottom