Solved Random Numbers (1 Viewer)

smtazulislam

Member
Local time
Today, 20:36
Joined
Mar 27, 2020
Messages
806
I would like to create random numbers with 3 or 4 digits by choice.
But I don't know how to create a table then this it works perfectly.
My table name is "tblGenerateNumbers".
My form name is "frmGenerateNumbers"

Here I have 10 digits and If I selected a 3 digit then it will generate the random numbers.

Example:
I choose " 3 and 5 and 9" then generate random numbers with 3 digits.
Please see the attached file form.
Any help will be appreciated.

EDIT: / UPDATE the dB.
 

Attachments

  • Database V1.accdb
    680 KB · Views: 448
Last edited:

smtazulislam

Member
Local time
Today, 20:36
Joined
Mar 27, 2020
Messages
806
Not yet I try it.
How to start it I dont have any idea.
Use case function or Others
what is the good ways. and how to save the data in the table.
Cloud you give me a little idea of starting line.....

I try selecting anyone the checkbox, First digit Or Middle digit Or Last Digit we choose
Chosen digit should insert first or Middle or Last ...
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 12:36
Joined
Feb 28, 2001
Messages
27,182
Using the RND(x) function, which gives you a SINGLE fraction between 0 and x (non-inclusive of the endpoints), you can generate a 3-digit number from 0 to 999 with

FIX( RND( 1000.0 ) )

If you use the RANDOMIZE function at some point early in your session, it is good for the entire session. If you DON'T use RANDOMIZE, you can (will) repeat the sequence that you used previously. When I wanted non-repeating random numbers, I usually fired off a RANDOMIZE during the OnLoad event code of my opening form. All subsequent calls to RND were effectively if not actually random.

Note carefully that the RND function is NOT a DOUBLE number. It has no more than 6 digits and no guarantees that the last digit is truly random (depending on the first digit if you are driving for 6 digits).

Saving the number in a table is possible, but you might need to search this forum for other articles on random numbers. Is there some reason you want to store random numbers? Or wouldn't you want to continue to randomly generate new numbers? There is a logical disconnect in the idea of storing random numbers since once you store them, they aren't random any more. Use the first time? No problem. Use the same table a second time? Not random any more.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 12:36
Joined
Feb 28, 2001
Messages
27,182
Oops- wrong version of BASIC. To get a number between 0 and 999 use

FIX( 1000.0 * RND( ) )
 

smtazulislam

Member
Local time
Today, 20:36
Joined
Mar 27, 2020
Messages
806
Thanks to all.
You all suggest I absolutely appreciated it.
But, I want to do like that,
I don't know using rnd() function or Others ways be solve this problem.
How can I do that.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:36
Joined
Oct 29, 2018
Messages
21,473
Thanks to all.
You all suggest I absolutely appreciated it.
But, I want to do like that,
I don't know using rnd() function or Others ways be solve this problem.
How can I do that.
I, for one, am not sure I understand your problem. You gave a sample form with a bunch of unbound textboxes, but kept saying you want to use a table to store the random numbers. Also, I don't get what the checkboxes on the form are for.

Can you please explain in more detail what it is you're trying to achieve? If you like, you might also provide some sample data to help explain what you're trying to do.
 

smtazulislam

Member
Local time
Today, 20:36
Joined
Mar 27, 2020
Messages
806
I selected 3 Checkbox numbers (1 And 4 And 7) these numbers is created random, Maybe 20 or 25 or 30.... I Insert 30 Unbound fileds.
Secondly Insert number If I chose from check box FIRST digit 7 then the first Numbers is 7.
See more details in the picture.
1.PNG

If I put numbers in the Middle text box "1" then It is inserted Middle digit is 1
See more details example in the picture
Middle Numbers.PNG


EDIT :
after generating the numbers I would like to save them in the table.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:36
Joined
Oct 29, 2018
Messages
21,473
I selected 3 Checkbox numbers (1 And 4 And 7) these numbers is created random, Maybe 20 or 25 or 30.... I Insert 30 Unbound fileds.
Secondly Insert number If I chose from check box FIRST digit 7 then the first Numbers is 7.
See more details in the picture.
View attachment 94137
If I put numbers in the Middle text box "1" then It is inserted Middle digit is 1
See more details example in the picture
View attachment 94138
Okay, let me see if I get it straight. You want to generate random 3-digit numbers. The checkboxes specify what digits to use, so you have to select only 3 and no more. The textboxes specify in which place each selected checkbox digit is supposed to go. Is that correct?

If so, I have a question. So, in your sample, you placed 7 in the first number box but didn't put anything else in the other boxes. Likewise, you put 1 in the second box but removed the 7 from the first box. Does that mean you can only specify one of those boxes? Also, does this setup also mean you cannot have duplicate numbers in different placement of the 3-digit random number? For example, if you put 7 in the first box, does it mean you can't have the following sample random numbers in the result?

774
717
747
etc...
 

smtazulislam

Member
Local time
Today, 20:36
Joined
Mar 27, 2020
Messages
806
The checkboxes specify what digits to use, so you have to select only 3 and no more.
No sir, I just an example that selected 3 checkboxes.
But, It does not only allow selected "3 " Checkboxes. it's multiple (0-9) Admin can choose, But the condition minimum 3 Checkboxes select. .
you placed 7 in the first number box but didn't put anything else in the other boxes.
Likewise, you put 1 in the second box but removed the 7 from the first box. Does that mean you can only specify one of those boxes? Also, does this setup also mean you cannot have duplicate numbers in different placement of the 3-digit random number?
For example, if you put 7 in the first box, does it mean you can't have the following sample random numbers in the result?

774
717
747
etc...
Yes, I don't like to duplicate numbers. Should the first digit is "7" and your example is right.
Generate numbers should be followed which checkboxes is selected.
774
713
722
709
723
752 etc
But if I enter the Middle numbers "1" then generate like that
612
019
218
918
718
215 etc
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 10:36
Joined
Oct 29, 2018
Messages
21,473
Yes, I don't like to duplicate numbers. Should the first digit is "7" and your example is right.
Generate numbers should be followed which checkboxes is selected.
774
713
722
709
723
752 etc
Still not there yet... So, with the above sample random number, we know you selected the checkbox for number 7 and also put 7 in the first textbox. Other than that, what other checkboxes you have selected and what other numbers would you have entered as second or third to get those results? Also, you said you don't like to duplicate numbers, but you gave the following sample results:

774 and 722
(duplicate 7s and 2s)

I thought you didn't want those.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:36
Joined
May 7, 2009
Messages
19,242
you can only have 6 generated numbers with your setup.
 

Attachments

  • Database V1.accdb
    672 KB · Views: 408

smtazulislam

Member
Local time
Today, 20:36
Joined
Mar 27, 2020
Messages
806
you can only have 6 generated numbers with your setup.
Thank you very much. Yes, that I needs.
But why only 6 Numbers. I need many many numbers much possible to auto generated.
Here, In the numbers section (0-9) I can't selecting more numbers, here support only 3 numbers. I would like select more numbers. but must be minimum 3 numbers select.

EDIT/
Also generated result, I want save it in the table "tblGenerateNumbers"
 
Last edited:

smtazulislam

Member
Local time
Today, 20:36
Joined
Mar 27, 2020
Messages
806
Still not there yet... So, with the above sample random number, we know you selected the checkbox for number 7 and also put 7 in the first textbox. Other than that, what other checkboxes you have selected and what other numbers would you have entered as second or third to get those results?
this 3 numbers fields, Can choose only ONE field.
if enter the First Fields then Middle and Last two fields is Blank.
if enter the Middle Fields then First and Last two fields is Blank.
if enter the Last Fields then First and Middle two fields is Blank.

Also, you said you don't like to duplicate numbers, but you gave the following sample results:

774 and 722
(duplicate 7s and 2s)

I thought you didn't want those.
I meant duplicate is like : "777 then 777 " Or "147 then 147
Its not duplicate numbers Like : 774 or 722 Or 117 Or 007...
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:36
Joined
May 7, 2009
Messages
19,242
you try to "google", "how many combination can be made for 3 numbers?"
all will answer 6 combinations.
 

smtazulislam

Member
Local time
Today, 20:36
Joined
Mar 27, 2020
Messages
806
how many combination can be made for 3 numbers?
Sir, you misunderstanding of my required.
I dont like to select only 3 numbers. I would like select (0-9) numbers. It was depend of Admin chosen Maybe select "All" or Choose numbers as mind. But must be or minimum 3 up numbers.

Just I want to from you "Multiple numbers select.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:36
Joined
May 7, 2009
Messages
19,242
then you will run out of textbox when you have 5 digit combination (120 combinations!).
also consider if you picked an even number of combination, eg: 1-2-3-4, which one
will be your Middle number?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 12:36
Joined
Feb 28, 2001
Messages
27,182
Our problem is that once you start selecting which numbers are to be used, your "no duplicates" rule will limit how many numbers you can generate and at that point, the sequence might be random but the numbers in a group will not be. This is simple combinatorial mathematics. What you have stated as your goal has mathematical limits that NO database would be able to do differently that what we are suggesting.

Although we appear to be communicating here, I suspect there is an issue of a language barrier that is clouding our understanding of your goals. The "idea" that you are trying to communicate isn't making it so clearly.

May I suggest that you stop telling us what you want at the low level of selecting numbers and tell us what is the 20,000 foot view of the process you are trying to support? If we can get a perspective that doesn't involve complex forms and selection sequence diagrams, and instead use ONLY language to describe your goals, perhaps we can help you better.
 

smtazulislam

Member
Local time
Today, 20:36
Joined
Mar 27, 2020
Messages
806
then you will run out of textbox when you have 5 digit combination (120 combinations!).
I think, Now you understand my opinion. No problem, I can make 120 textboxes or more.
also consider if you picked an even number of combination, eg: 1-2-3-4, which one
will be your Middle number?
if I will be selected "1 - 2 - 3 - 4 - 5 - 6" or more numbers. Then selected those numbers to CHOOSE ANY "1" digit and ENTER in the Middle Or First Or Last.

Example:
Now I selected Checkbox "0 - 9 - 2 - 3 - 4 - 5 - 6"
and Middle I enter "4"
945
346
349
049
546
948
849............................ etc then save it.

if I enter the First "6"
645
629
634
649
658
675
677........... etc then save it.
 

Users who are viewing this thread

Top Bottom