
Signature
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
Thanks Allen
I am still struggling with this.
I am using Access as the data source for an ASP web page. Every time I run
the query from the ASP page, I get the same record id.
I created a module with the following function:
Public Function CallRandomizer()
Randomize
End Function
I then created a macro named AutoExec that calls CallRandomizer() under the
RunCode action.
I then quit and re-started the database and also closed and reloaded the
browser.
Each time I try to retrieve a random ID from the web page I get the same ID
(186). When I run the query directly from within Access, I always get 186
first, followed by 1291, 1111. If I shut down and restart Access, I will
encounter the same sequence (186, 1291, 1111) after it is re-opened.
So I apparently can't get this to work on any level (ASP or Access).
Do you see what I might be doing wrong?
> You can do it by pressing Ctrl+G (to open the Immediate window), typing:
> Randomize
[quoted text clipped - 48 lines]
>>>>
>>>> How can I write a query that returns a random record?
Allen Browne - 30 May 2006 02:20 GMT
If there is no instance of Access running (i.e. you are just connecting to
the data from different software), then it will not be possible to issue a
Randomize in Access, so you will get the repeating number.
Perhaps you could ask in an ASP group how to get a random number. (You may
have to do something like opening a recordset, moving to the last record,
getting the record count, and moving back a random number of records.)

Signature
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
> Thanks Allen
>
[quoted text clipped - 76 lines]
>>>>>
>>>>> How can I write a query that returns a random record?
Wei Lu - 30 May 2006 05:36 GMT
Hi Dave,
I think you could use the Randomize function in the ASP script.
Here are some articles for your reference.
http://groups.google.com/group/microsoft.public.inetserver.asp.db/browse_frm
/thread/1191db894f771e58/282e6c3694299be8
http://groups.google.com/group/microsoft.public.scripting.vbscript/browse_fr
m/thread/67b6295ccaa7ca26/fddeeaa2f3ce9dfb
Hope this will be helpful.
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.