Runtime Error 7951

  • Thread starter Thread starter JamesJ
  • Start date Start date
J

JamesJ

Hi. This happens whenever I create a new form and copy/paste the OnCurrent
code from
one form into the new one. It works fine in the old form but when I try to
open the new form
I get the following error:

'Run-time Error '7951':'

'You entered an expression that has an invalid reference to the
RecordsetClone property.'

This has happened before but I can't remember how I fixed it.
Any help will be appreciated.

Thanks,
James
 
Sorry. Here's the code for the OnCurrent.

Private Sub Form_Current()

Dim RecClone As DAO.Recordset
Dim intCount As Integer
Dim intPosition As Integer

Set RecClone = Me.RecordsetClone()

If IsNull(Me.ctlRecID) Then

Else

RecClone.MoveLast
intCount = RecClone.RecordCount
RecClone.Bookmark = Me.Bookmark
intPosition = RecClone.AbsolutePosition + 1
lblCount.Caption = "Record " & intPosition & " of " & intCount

End If

RecClone.Close
Set RecClone = Nothing

End Sub

James
 
I've never seen it used this way so let's try getting rid of
the () after RecordsetClone.

A potential problem is the statement:
RecClone.Close
You didn't open that recordset so you should not try to
Close it.
 
I got it to work now and I don't recall how. I'm just using
it to display the record number and the number of records
being displayed in the recordset. I'm always open for
suggestions if there is a better way.

Thanks,
James

Marshall Barton said:
I've never seen it used this way so let's try getting rid of
the () after RecordsetClone.

A potential problem is the statement:
RecClone.Close
You didn't open that recordset so you should not try to
Close it.
--
Marsh
MVP [MS Access]


Sorry. Here's the code for the OnCurrent.

Private Sub Form_Current()

Dim RecClone As DAO.Recordset
Dim intCount As Integer
Dim intPosition As Integer

Set RecClone = Me.RecordsetClone()

If IsNull(Me.ctlRecID) Then

Else

RecClone.MoveLast
intCount = RecClone.RecordCount
RecClone.Bookmark = Me.Bookmark
intPosition = RecClone.AbsolutePosition + 1
lblCount.Caption = "Record " & intPosition & " of " & intCount

End If

RecClone.Close
Set RecClone = Nothing

End Sub

James
 
Back
Top