Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Textbook style connection

Status
Not open for further replies.

Aelstro

Technical User
Jun 17, 2003
24
US
I'm
using the ADO database object model so the DAO/ADO issue shouldn't be a
problem. I'm trying to select all records in a column of a table and
display them. here is the code

Sub SelectAllFields()
Dim strSQL As String

'Query, selecting all fields from the ClientList table
strSQL = "Select * FROM ClientList"

'Pass arguments to Preview
PreviewRecord (strSQL)
End Sub

Sub PreviewRecord(strSQL As String)
Dim rst1 As Connection
Dim fld1 As Field
Dim intl As Integer

Set rstl = CurrentProject.Connection
rst1.Execute strSQL <-----The Error is here ****

'Loop through first 10 records,
'and print all non-OLEobject fields to the
'immediate window

intl = 1
Do Until rst1.EOF
Debug.Print &quot;Output for record: &quot; & intl
For Each fld1 In rst1.Fields
If Not (fld1.Type = adLongVarBinary) Then
Debug.Print String(5, &quot; &quot;) & fld1.Name & &quot; = &quot; & fld1.Value
End If
Next fld1
rst1.MoveNext
If int1 >= 10 Then
Exit Do
Else
intl = intl + 1
Debug.Print
End If
Loop
'Clean up objects
rst1.Close
Set rest1 = Nothing
End Sub

When I add a watch rst1 is never defined by the &quot;Set rst1&quot; statement.
Error message: Runtime Error 91: Object variable or With variable not set.

Why isn't my variable being set?
 
Oh thank you in advance to anyone who helps. (Forgot to put it on my last message)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top