Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

random number for a column inside WITH loop for all records

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

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…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
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…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

840 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