Solved

random number for a column inside WITH loop for all records

Posted on 2011-03-02
2
332 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

685 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