Thread: Object required
View Single Post
  #1 (permalink)  
Old November 8th, 2007, 04:41 PM
jpaul jpaul is offline
Authorized User
 
Join Date: Nov 2007
Location: Nederland, , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default Object required

I'm using the example from the book "Beginning Access 2003 VBA
the "PopulateControlsOnForm" sub.
Code:
=================================

Private Sub Form_Load()
On Error GoTo Err_Form_Load_Click

     Dim Cnx As ADODB.Connection 'Declares the Object Varibles
     Dim Rst As ADODB.Recordset

    Set Cnx = New ADODB.Connection 'sets the Connection
    Set Rst = New ADODB.Recordset 'sets the Recordset

    Cnx.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Access.CurrentDb.Name & ";Persist Security Info=False"
    Cnx.Open

    If Rst.State = 1 Then Rst.Close

   Rst.Open "Select * From tblLog order by [Date]", Cnx, adOpenKeyset, adLockOptimistic

    If Rst.BOF And Rst.EOF Then
        Exit Sub
        Else
            Rst.MoveFirst
            Call PopulateControlsOnForm
    End If


         Rst.Close
         Cnx.Close
         Set Rst = Nothing
         Set Cnx = Nothing
         Me.Filter = Me.Filter
         Me.Refresh

Exit_Form_Load_Click:
        Exit Sub

Err_Form_Load_Click:
        MsgBox Err.Description
        Resume Exit_Form_Load_Click

=================================
Sub PopulateControlsOnForm()

If Not Rst.BOF And Not Rst.EOF Then
    txtLogDate.Value = Rst.Field("Date")
    Me.tbProj = Rst.Fields("Project")
    Me.tbInTime = Rst.Fields("InTime")
    Me.txtOuttime = Rst.Fields("outTime")
    Me.CrgHrs = Rst.Fields("CrgHrs")
    Me.MLog = Rst.Fields("Log")
Else
If Rst.BOF Then
    Rst.MoveNext
Else
If Rst.EOF Then
   Rst.MovePrevious
End If
End If
End If

End Sub
===========================
I've also used the book code example" Me.tbLogDate = rst!Date

Using my recordset as "Rst." and my table & object names.

I'm getting and error "no object"
So it cant find the recordset object. I've also duplicated the book code exactly (except my table names etc.)

Has anyone else experienced the same problems from this book and is there a solution?
Thanks


Reply With Quote