[AccessD] Random rows ?

Heenan, Lambert Lambert.Heenan at AIG.com
Wed Oct 22 16:18:25 CDT 2008


Right 'Replication ID' gives you a filed containing GUID strings.

Lambert 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Bob Heygood
Sent: Wednesday, October 22, 2008 5:12 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Random rows ?

Hello,

I don't think I can have more than one autonumber field in a table.
I do not see where I can create a "Autonumber Guid". Did you mean
"Replication ID"?
A2003

My client has relented and accepted the resulting text file in order.

I still think there is an easy way to do this tho.....

Thanks for your response.

Bob Heygood



 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
Sent: Wednesday, October 22, 2008 1:35 PM
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] Random rows ?

Hi Bob

One method is to create the table with two fields:

  Guid - Autonumber Guid
  > save table, then:
  Id - Autonumber Long, Format: 0000000

Now, run this sub:

Public Sub T2M()
  Dim rst As DAO.Recordset
  Dim lngCount As Long
  
  Set rst = CurrentDb.OpenRecordset("tblRandom")
  
  For lngCount = 1 To 2000000
    rst.AddNew
    ' A record is created. Save it.
    rst.Update
  Next
  rst.Close
  Set rst = Nothing
End Sub

This will take a while to run as the table continuously sorts on the (by
nature) random Guid. However, this is what you want as - when you open the
table - it will be sorted by the Guids, thus the Ids appear in random order.
To preserve the formatted field Id, you may at this point add a new text
field of length seven which you update to the formatted value of field Id;
if the table is fixed, you may now choose to delete the Id field.

/gustav

>>> bheygood at abestsystems.com 22-10-2008 18:59 >>>
Hello to the list,

I need to create a table of one row that looks like below:

0000001
0000002
0000003

2000000


I have had no problem so far.

But the client wants the table output to be random. Like:

1114453
0000022
2000000
0048941
And so forth. And of course no repeating rows......

Any thoughts??

Bob



--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list