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
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