troubleshooting Question

Access 07 ADO Runtime error 91

Avatar of jbakerstull
jbakerstull asked on
Microsoft Access
5 Comments2 Solutions314 ViewsLast Modified:
When I run the subroutine with syntax code I receive run time error 91 Object variable or with block variable not set at line rst.ActiveConnection = conn.

I'm not sure exactly why I'm receiving this error. Goal is to display table details via immediate window.

Thanks
Sub Open_Table()
   Dim conn As ADODB.Connection
   Dim rst As ADODB.Recordset
   Dim fld As ADODB.Field

    rst.ActiveConnection = conn

   Set conn = New ADODB.Connection
   
   Set rst = New ADODB.Recordset
    
    rst.Open "Select * from tblDisabilityElig", conn, adOpenKeyset, adLockOptimistic
    Do Until rst.EOF
       For Each fld In rst.Fields
          Debug.Print fld.Name & "=" & fld.Value
       Next fld
       rst.MoveNext
   Loop
   rst.Close
   Set rst = Nothing
   conn.Close
   Set conn = Nothing
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros