Solved

random number for a column inside WITH loop for all records

Posted on 2011-03-02
2
297 Views
Last Modified: 2012-06-27
can you just have a random number for a column for all records within a WITH loop?
      With ds
        .AddNew
<columns> values assigned
<Column5, for example should have the same random number for all the records updated within the WITH loop>
<In the next time the loop is run, all the Column5 column values should have the a random number, but all same just for that loop
etc>
        .Update
      End With

for example, in the first loop with the first flat file, there may be 3 records for example.For all 3 records, the 5th column should have the same random number.

example:
1,2,3,4,563843347
2,3,4,5,563843347
3,4,5,6,563843347

In the second loop, there may be 7 rows for example, but all of the 5th column should have the same random number together again.

11,12,13,14,270267623
22,33,44,55,270267623
33,44,55,66,270267623
1,11,21,31,270267623
2,22,33,44,270267623
3,4,5,6,270267623
9,0,9,0,270267623

how can this be done?

Thanks
0
Comment
Question by:anushahanna
2 Comments
 
LVL 2

Accepted Solution

by:
clayhopkins earned 500 total points
ID: 35024331
Set a var to a random number just before entering the loop.  If this code is inside a method, for instance, every time the method is called, a new random number will be created before entering the loop the next time.  Assign the value in the var holding the random number to column 5.
0
 
LVL 6

Author Comment

by:anushahanna
ID: 35028635
thanks!
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now