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
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