How to generate a range of numbers between two numbers? (1 Viewer)

Leo2019

New member
Local time
Today, 06:46
Joined
Jul 27, 2019
Messages
8
Hello Everyone!

In our company, we handover a number of booklets to our delegates and we need to track the serial numbers with each one.
So, I've created a form to record the starting & ending range of the booklets, I need VBA to list a preview to the booklets within the written range when I hit the button ( Preview) which will record 3 fields ( Delegate, Date, & Booklet number ) for each of the booklets.

Then, after reviewing the numbers & make sure they are accurate, I shall hit the other button "Register" to add them to the table.

A quick introduction to the database:
1- (Table) Delegates: Stores the names of the delegates.
2- (Table) Temp_Delegates_Booklets: Stores the preview data, erase all data each time ahead of the preview.
3- (Table) Delegates_Booklets: Stores the final data after revision.
4- (Form) Register_Booklet: The interface for the entry process.
5- (Form) Temp_Delegates_Booklets subform: Preview the data of the booklets before storing them in #3 (Table) Delegates_Booklets

Thanks in advance :)
 

Attachments

  • Booklets.accdb
    1.5 MB · Views: 179

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 20:46
Joined
Oct 29, 2018
Messages
21,453
Hi. Are you trying to create multiple records with sequential numbers for the booklet numbers? If so, you might look into using a Tally table. Are you planning to enter any data in the "preview" subform?
 

Leo2019

New member
Local time
Today, 06:46
Joined
Jul 27, 2019
Messages
8
Hi. Are you trying to create multiple records with sequential numbers for the booklet numbers? If so, you might look into using a Tally table. Are you planning to enter any data in the "preview" subform?
Hi DBguy!
Appreciate your fast response.

Yes. It's sequential numbers.
I don't know what a Tally table is.
No, I'm using the preview for checking only, if there is another way without the need to use it, this would be great.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 20:46
Joined
Oct 29, 2018
Messages
21,453
Hi DBguy!
Appreciate your fast response.

Yes. It's sequential numbers.
I don't know what a Tally table is.
No, I'm using the preview for checking only, if there is another way without the need to use it, this would be great.
Hi. Check out this article to see what I mean by a Tally table.
 

plog

Banishment Pending
Local time
Yesterday, 22:46
Joined
May 11, 2011
Messages
11,638
Weird, this is almost exactly like this thread:


I'll reconfigure my post from there:

This is pretty simple, even if you don't know VBA I suggest you give it a shot. I'll help by writing the psuedo code:

Code:
Sub AddBooklets()

for i=0 to Me.BookletsTo
DoCmd.RunSQL("INSERT INTO YourTable (BookletsNumberField) VALUES (" & i + Me.BookletsFrom " &")")
Next i
End Sub

Again, that's pseudo code which means it illustrates the ideas you need in your code but not the exact syntax.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:46
Joined
May 7, 2009
Messages
19,231
sample db (a2007).
 

Attachments

  • Booklet.accdb
    596 KB · Views: 244

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 20:46
Joined
Oct 29, 2018
Messages
21,453
Thank you @theDBguy I've checked the article, I'll give it a try & feedback.
I have also posted a demo using a Tally table in this other thread.
 

Leo2019

New member
Local time
Today, 06:46
Joined
Jul 27, 2019
Messages
8
Thank you @arnelgp
I guess the booklets in your sample db requires to be registered in the table, right?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:46
Joined
May 7, 2009
Messages
19,231
Yes you have to put all the booklet in the table first.
 

Users who are viewing this thread

Top Bottom