Private Sub SetRst()
Dim strSQL As String
Dim rst As ADODB.Recordset
Const strProcedure As String = "SetRst"
10 On Error GoTo ErrorHandler
20 strSQL = "SELECT Item1, Item2, Item3, Item4, Item5, Item6, " & _
"EvaluationID, FormID FROM tblItems WHERE EvaluationID = " & _
lngEvalID & " AND FormID = " & lngFormID
30 Set rst = New ADODB.Recordset
40 With rst
50 .Open strSQL, CurrentProject.Connection, _
adOpenKeyset, adLockOptimistic, adCmdText
' Check if any records were retrieved
60 If Not (.BOF And .EOF) Then
70 Set Me.Form.Recordset = rst
80 Else
90 MsgBox "No Records Found!"
100 .Close
110 Set rst = Nothing
120 End If 'If Not (rst.RecordCount = 0)
130 End With 'With rst
ExitSub:
140 On Error GoTo 0
150 Exit Sub
ErrorHandler:
160 HandleError strModule, strProcedure, Err.Description, Err.Number, Erl
170 Resume ExitSub
End Sub
|