Need Help - Random Numbers

W

Wayne

In order to comply with SAS70 (SarBox)I need to pull the
top five records from our tax research database for
testing.

I found this code on the internet and made mod's according
to my tables. When I attempt to run the code I get an
error message "Compile error. Network may not be
accessible". The file is on my HD not the network. Any
ideas? Below is the code (I am not a p'grmer) so any ideas
or other places to look would be helpful. I also tried the
MS solution (Northwinds db) and that had the same error.
TIA

Attribute VB_Name = "GetRandomData"

Sub PickRandom()
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Dim rst As DAO.Recordset
Dim strSQL As String
Dim strTableName As String

strSQL = "SELECT AuditTable.[state abbr],
AuditTable.combinedtopic " & _
"INTO tblTemp " & _
"FROM AuditTable;"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True

Set db = CurrentDb()
Set tdf = db.TableDefs("tblTemp")
Set fld = tdf.CreateField("RandomNumber", dbDouble)

tdf.Fields.Append fld

Set rst = db.OpenRecordset("tblTemp", dbOpenTable)

rst.MoveFirst
Do
Randomize
rst.Edit
rst![RandomNumber] = Rnd()
rst.Update
rst.MoveNext
Loop Until rst.EOF

rst.Close
Set rst = Nothing

strTableName = "tblRandom_" & Format(Date, "ddmmmyyyy")
strSQL = "SELECT TOP 25 Audittable.[state abbr],
AuditTable.combinedtopic
" & _
"INTO " & strTableName & " " & _
"FROM tblTemp " & _
"ORDER BY tblTemp.RandomNumber;"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True

db.TableDefs.Delete ("tblTemp")
End Sub
 
T

Tim Ferguson

When I attempt to run the code I get an
error message "Compile error. Network may not be
accessible". The file is on my HD not the network. Any
ideas?

If memory serves, this is a symptom of corruption due to an unpatched
version of Access 2000. Copy the database, then compact-and-repair, then
compile the code. And get your copy of Access updated to the current
service pack.

Hope that helps


Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top