a simple question on ADODB

  • Thread starter Thread starter joyo
  • Start date Start date
J

joyo

I am new to the ADODB, below is my code. It is pretty easy and simple
code, but I don't know why I just keep getting the error message.

Private Sub Form_Load()
Dim cnn As ADODB.Connection
Dim cust As ADODB.Recordset
Set cnn = CurrentProject.Connection
cust.Open "SELECT * FROM tbl_TmpTblInfor", cnn
Do Until cust.EOF
Debug.Print cust!TblName
cust.MoveNext
Loop

End Sub


The error message is

Runtime error 91,
object variable or with block variable not set.

Your help will be highly appreciated.

Thanks

joyo
 
joyo said:
I am new to the ADODB, below is my code. It is pretty easy and simple
code, but I don't know why I just keep getting the error message.

Private Sub Form_Load()
Dim cnn As ADODB.Connection
Dim cust As ADODB.Recordset
Set cnn = CurrentProject.Connection
cust.Open "SELECT * FROM tbl_TmpTblInfor", cnn
Do Until cust.EOF
Debug.Print cust!TblName
cust.MoveNext
Loop

End Sub


The error message is

Runtime error 91,
object variable or with block variable not set.

Your help will be highly appreciated.

Thanks

joyo

You need to actually create the recordset object before you open it:
 
Back
Top