Solved

random number for a column inside WITH loop for all records

Posted on 2011-03-02
2
336 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
[X]
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
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

734 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