I have been asked to look at the following code for a co-worker. I'm a newbie to this stuff and I'm not sure what is causing the message "Object variable or With block variable not set" message when attempting to run the code. Any help would be appreciated.



Dim ODBC_Workspace As Workspace
Dim ODBC_Connection As Connection
Dim DB As Database
Dim RS_In As Recordset
Dim RS_Out As Recordset
Dim Criteria As String
Dim JobName(4, 7) As Double
Dim JNAME_Index As Integer
Dim Field_Index As Integer

Criteria = "[CDATE] >= " & parmFromDate & " And [CDATE] <= " & parmToDate

Set ODBC_Workspace = CreateWorkspace("ODBC_Workspace01", "CQ11", "", dbUseODBC)
Set DB = DBEngine.Workspaces(0).OpenDatabase(CurrentDb().Na me)
Set ODBC_Connection = ODBC_Workspace.OpenConnection("ODBC_Connection01", _
dbDriverPrompt, True)
'Debug.Print ODBC_Connection.Connect
Set RS_In = ODBC_Connection.OpenRecordset("SYSADM_DB_A02", dbOpenForwardOnly)
Set RS_Out = DB.OpenRecordset("tblStatisticalCounts", DB_OPEN_DYNASET)

Aaron_Test = True

For JNAME_Index = 1 To 4
For Field_Index = 1 To 7
JobName(JNAME_Index, Field_Index) = 0
Next Field_Index
Next JNAME_Index

With RS_In
.FindFirst Criteria
Do Until .NoMatch
JNAME_Index = 4
If !JNAME = "IWAYTCIS" Then
JNAME_Index = 1
End If
If !JNAME = "IWAYTEST" Then
JNAME_Index = 2
End If
If !JNAME = "SCICPAPR" Then
JNAME_Index = 3
End If
JobName(JNAME_Index, 1) = JobName(JNAME_Index, 1) + !REQS
JobName(JNAME_Index, 2) = JobName(JNAME_Index, 2) + !ETIME
JobName(JNAME_Index, 3) = JobName(JNAME_Index, 3) + !RTIME
JobName(JNAME_Index, 4) = JobName(JNAME_Index, 4) + !WTIME
JobName(JNAME_Index, 5) = JobName(JNAME_Index, 5) + !EXCPS
JobName(JNAME_Index, 6) = JobName(JNAME_Index, 6) + !EXCDT
JobName(JNAME_Index, 7) = JobName(JNAME_Index, 7) + !EXCIX
.FindNext Criteria
Loop
End With

For JNAME_Index = 1 To 4
With RS_Out
.AddNew
Select Case JNAME_Index
Case 1
!JobName = "IWAYTCIS"
!SortOrder = "01"
Case 2
!JobName = "IWAYTEST"
!SortOrder = "02"
Case 3
!JobName = "SCICPAPR"
!SortOrder = "03"
Case 4
!JobName = "PACER BATCH"
!SortOrder = "04"
End Select
!Requests = JobName(JNAME_Index, 1)
!ElapsedTime = JobName(JNAME_Index, 2) / 60
!RunTime = JobName(JNAME_Index, 3) / 60
!WaitTime = JobName(JNAME_Index, 4) / 60
!IO_Total = JobName(JNAME_Index, 5)
!IO_Data = JobName(JNAME_Index, 6)
!IO_Index = JobName(JNAME_Index, 7)
.Update
End With
Next JNAME_Index


Exit_Aaron_Test:
RS_In.Close
RS_Out.Close
ODBC_Connection.Close
MsgBox "Finished ODBC Test"
Exit Function

'MsgBox "Copy / delete routine completed", 16, CStr(Err) & "ODBC Processing"
'LogWork.CommitTrans
Err_Aaron_Test:
MsgBox Error$, 16, CStr(Err) & " Aaron Test "
'LogWork.Rollback
'Resume Exit_ODBC_Test
RS_In.Close
RS_Out.Close
ODBC_Connection.Close
Exit Function