Solved

random number for a column inside WITH loop for all records

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

864 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

21 Experts available now in Live!

Get 1:1 Help Now