MwTV
MIS
- Mar 9, 2007
- 99
Assistance needed.
Receiving "Member Not Found" error upon trying to run following function with a macro. Specifically, "Records Affected" is highlighted and "Member Not Found" is displayed.
(Note, function is used to run 10 make-table queries in sequence using Windows Scheduler)
Public Function fQueryBatch() As Byte
Dim strSQL As String
strSQL = "SELECT * FROM tblQueriesToRun ORDER BY QueryOrder ASC"
On Error GoTo Err_fQueryBatch
With CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
'Loop through the queries to run
Do Until .EOF
'Open the record that tracks the query and record the start
.Edit
.Fields("DateTimeQueryStarted") = Now()
'Run the query
DoCmd.SetWarnings False
CurrentDb.Execute .Fields("QueryName"), dbFailOnError
DoCmd.SetWarnings True
'Record more stats and save the record
.Fields("DateTimeQueryEnded") = Now()
.Fields("RecordsReturnedByQuery") = .RecordsAffected
.Update
'Move to the next record
.MoveNext
Loop
End With
fQueryBatch = True
Exit Function
Err_fQueryBatch:
fQueryBatch = False
End Function
'Incorporate the following five lines to check to see if all queries were run successfully
'If RunQuery("QueryName") = True Then
' MsgBox "Query was successful", vbInformation
'Else
' MsgBox "Query was not successful", vbExclamation
'End If
Receiving "Member Not Found" error upon trying to run following function with a macro. Specifically, "Records Affected" is highlighted and "Member Not Found" is displayed.
(Note, function is used to run 10 make-table queries in sequence using Windows Scheduler)
Public Function fQueryBatch() As Byte
Dim strSQL As String
strSQL = "SELECT * FROM tblQueriesToRun ORDER BY QueryOrder ASC"
On Error GoTo Err_fQueryBatch
With CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
'Loop through the queries to run
Do Until .EOF
'Open the record that tracks the query and record the start
.Edit
.Fields("DateTimeQueryStarted") = Now()
'Run the query
DoCmd.SetWarnings False
CurrentDb.Execute .Fields("QueryName"), dbFailOnError
DoCmd.SetWarnings True
'Record more stats and save the record
.Fields("DateTimeQueryEnded") = Now()
.Fields("RecordsReturnedByQuery") = .RecordsAffected
.Update
'Move to the next record
.MoveNext
Loop
End With
fQueryBatch = True
Exit Function
Err_fQueryBatch:
fQueryBatch = False
End Function
'Incorporate the following five lines to check to see if all queries were run successfully
'If RunQuery("QueryName") = True Then
' MsgBox "Query was successful", vbInformation
'Else
' MsgBox "Query was not successful", vbExclamation
'End If