# Thread: Create sequence of numbers

i want to make a loop with this number and have a sequence of number do until 10.

example for My_var 7111297074:

7111297074
7111297075
7111297076
7111297077
7111297078
7111297079
7111297080

example for My_var 7111297047:

7111297047
7111297048
7111297049
7111297050

2. [quote name='sal21' post='794815' date='25-Sep-2009 08:23']i want to make a loop with this number and have a sequence of number do until 10.

example for My_var 7111297047:

7111297047
7111297048
7111297049
7111297050[/quote]

If you want to stop the loop when it gets to the next '10', you can use the modulus command

[codebox]Do Until My_var Mod 10 = 0
My_var = My_var+1
... code

Loop[/codebox]

3. [quote name='Gfamily' post='794819' date='25-Sep-2009 09:45']If you want to stop the loop when it gets to the next '10', you can use the modulus command

[codebox]Do Until My_var Mod 10 = 0
My_var = My_var+1
... code

Loop[/codebox][/quote]

ok...
But how to dim my_var???
I have dimensione long and have error, double have error...

note:
the max lenght of My_mar is 10 numeric character

4. [quote name='sal21' post='794823' date='25-Sep-2009 08:57']ok...
But how to dim my_var???
I have dimensione long and have error, double have error...

note:
the max lenght of My_mar is 10 numeric character[/quote]

Dim My_Var as a Long, Double or whatever and another field (My_v2) as an Integer

then
My_v2 = Right(My_var,2)

Do until My_v2 Mod 10
My_v2 = My_v2 + 1

code...
Loop
etc

5. You can't use the Mod operator with such large numbers.
Declare my_Var as Double or as Currency, and use the following loop:

Code:
```Do Until Right(my_Var, 1) = "0"
...
my_Var = my_Var + 1
Loop```

6. [quote name='HansV' post='794833' date='25-Sep-2009 12:01']You can't use the Mod operator with such large numbers.
Declare my_Var as Double or as Currency, and use the following loop:

Code:
```Do Until Right(my_Var, 1) = "0"
...
my_Var = my_Var + 1
Loop```
[/quote]
now not completly understand....:-(

7. See the attached workbook.

8. No dubt you are the Champin!!

9. [quote name='HansV' post='794847' date='25-Sep-2009 14:40']See the attached workbook.[/quote]

but have a question about that.

I just have an opened a ADO connection with the tipical strig of conn to connect mdb database.
In other case the mdb is named ASS and is located in c:\mydir\
The table is named TASS
In to tabel have this fileds:

Prova01, prova02....prova10

Now how to insert the value of Debug.Print c + b into fields of table in this mode:

prova01=first element of loop, prova02=second element of loop... ecc

Naturally:
if the for next is =7 in this case the fileds to be filled are from prova01 to prova07
if the for next is =10 in this case the fileds to be filled are from prova01 to prova10

Hi hope you have understand me.
Tks for patience

Note:
But you italian is excellent now and improved, great school?

10. You have to declare a variable rst of type ADODB.Recordset, and open the recordset on the TASS table (you know how to do that).
If you want to create a new record, use rst.AddNew.

Then set the value of the fields:

Code:
```  my_Var = 7111296075#
r = 1
rst.Fields("ASS" & r) = my_Var
Do Until Right(my_Var, 1) = "0"
my_Var = my_Var + 1
r = r + 1
rst.Fields("ASS" & r) = my_Var
Loop
rst.Update
rst.Close```

11. [quote name='HansV' post='794879' date='25-Sep-2009 16:02']You have to declare a variable rst of type ADODB.Recordset, and open the recordset on the TASS table (you know how to do that).
If you want to create a new record, use rst.AddNew.

Then set the value of the fields:

Code:
```  my_Var = 7111296075#
r = 1
rst.Fields("ASS" & r) = my_Var
Do Until Right(my_Var, 1) = "0"
my_Var = my_Var + 1
r = r + 1
rst.Fields("ASS" & r) = my_Var
Loop
rst.Update
rst.Close```
[/quote]

R = 1
RS1.Fields("ASS" & R) = RR
Do Until Right(RR, 1) = "0"
RR = RR + 1
R = R + 1
RS1.Fields("ASS" & R) = RR
Loop
RS1.Update

?????????

12. Yes.

13. [quote name='HansV' post='794886' date='25-Sep-2009 16:15']Yes.[/quote]

Not append the new reset!!!!

ok resoved!
Tks as usual

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•