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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"ActiveX components can not create object" for record navigation

Status
Not open for further replies.

SwingXH

Technical User
Jun 15, 2004
97
US
I have a table named tblIdea. A form has been created to show the records of this table.
I have a command to make the form to show only records match the query, as in Private Sub ApplyADORecordset_Click(), only search Hours>=100.

The problem is that when I have this sub, there's an error in Sub cmdNext_Click() which is used to navigate the nexe record. The error message is "ActiveX components can not create object".
can any body help me on this?

Also, how to get the total number of the records that match the query?

Thanks a lot!
SwingXH


Private Sub ApplyADORecordset_Click()
Dim frm As Access.Form
Dim strSQL As String
Dim rst As ADODB.Recordset
strSQL = "SELECT * FROM tblIdea " & _
"WHERE Hours>=100;"
DoCmd.OpenForm "IdeaDatabase"
Set frm = Forms![IdeaDatabase]
Set rst = New ADODB.Recordset
rst.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
Set frm.Recordset = rst
End Sub

Private Sub cmdNext_Click()
On Error GoTo Err_cmdNext_Click

Me.RecordsetClone.Bookmark = Me.Bookmark
If Me.RecordsetClone.AbsolutePosition + 1 >= Me.RecordsetClone.RecordCount Then
MsgBox "At Last Record"
Else
DoCmd.GoToRecord , , acNext
End If
Exit_cmdNext_Click:
Exit Sub

Err_cmdNext_Click:
MsgBox Err.Description
Resume Exit_cmdNext_Click

End Sub
 
Are you sure you may set a form recordset to an ADODB one ?
Have you tried with a DAO.Recordset ?
You may have to reference the Microsoft DAO 3.x Object library.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top