Hello everyone. I'm using access '97 and I'm getting an error that I don't know how to correct. I have a form with a subform and as I go through the records and come to a record that has data in the subform I get this error.
"Object invalid or no longer set." The error seems to be in the on current event. Here it is:
Am I missing something? Can anyone help me?
Thanks in advance,
Jason
"Object invalid or no longer set." The error seems to be in the on current event. Here it is:
Code:
Private Sub Form_Current()
Dim recClone As Recordset
If Me.NewRecord Then
cmdNewRecord.Enabled = False
cmdAdd.Enabled = True
cmdCloseForm.Visible = False
Me.cmdCancel.Visible = True
Else
cmdNewRecord.Enabled = True
cmdAdd.Enabled = False
End If
If Me.NewRecord Then
cmdFirstRecord.Enabled = False
cmdNext.Enabled = False
cmdBack.Enabled = False
cmdLastRecord.Enabled = False
Exit Sub
End If
'THIS IS WHERE ACCESS SAYS THE ERROR IS
'Me.Recordsetclone = <object invalid or no longer set>
Set recClone = Me.RecordsetClone
If recClone.RecordCount = 0 Then
cmdFirstRecord.Enabled = False
cmdNext.Enabled = False
cmdBack.Enabled = False
cmdLastRecord.Enabled = False
Else
recClone.Bookmark = Me.Bookmark
recClone.MovePrevious
cmdFirstRecord.Enabled = Not recClone.BOF
cmdBack.Enabled = Not recClone.BOF
recClone.MoveNext
recClone.MoveNext
cmdLastRecord.Enabled = Not recClone.EOF
cmdNext.Enabled = Not recClone.EOF
recClone.MovePrevious
End If
Set recClone = Me.RecordsetClone
recClone.Close
End Sub
Am I missing something? Can anyone help me?
Thanks in advance,
Jason