S
So Call Me Crazy
I have code to handle the deletion of a record that appears on a form.
Deleted the current recordset on the form and then either moved to the next
record, or the previous, depending.... Worked great in 2003. Now getting an
error of type mismatch when setting the variable rst with RecordsetClone!
Huh?!? Here's the code:
Public Function DelCurrentRec(ByRef frmSomeForm As Form)
Dim rst As Recordset
Set rst = Nothing
On Error GoTo DelCurrentRec_Error
Application.Echo False
With frmSomeForm
Set rst = .RecordsetClone
rst.Bookmark = .Bookmark
If .Recordset.AbsolutePosition > 0 Then
.Recordset.MoveNext
Else
.Recordset.MovePrevious
End If
rst.Delete
If rst.EOF Then
.Recordset.MovePrevious
Else
If .Recordset.AbsolutePosition > 0 Then
.Recordset.MovePrevious
Else
.Recordset.MoveNext
End If
End If
End With
Application.Echo True
DelCurrentRec_Exit:
On Error Resume Next
rst.Close
Set rst = Nothing
Application.Echo True
Exit Function
DelCurrentRec_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & _
") in procedure DelCurrentRec of Module modRefresh"
GoTo DelCurrentRec_Exit
End Function
Thanks for your help!
Deleted the current recordset on the form and then either moved to the next
record, or the previous, depending.... Worked great in 2003. Now getting an
error of type mismatch when setting the variable rst with RecordsetClone!
Huh?!? Here's the code:
Public Function DelCurrentRec(ByRef frmSomeForm As Form)
Dim rst As Recordset
Set rst = Nothing
On Error GoTo DelCurrentRec_Error
Application.Echo False
With frmSomeForm
Set rst = .RecordsetClone
rst.Bookmark = .Bookmark
If .Recordset.AbsolutePosition > 0 Then
.Recordset.MoveNext
Else
.Recordset.MovePrevious
End If
rst.Delete
If rst.EOF Then
.Recordset.MovePrevious
Else
If .Recordset.AbsolutePosition > 0 Then
.Recordset.MovePrevious
Else
.Recordset.MoveNext
End If
End If
End With
Application.Echo True
DelCurrentRec_Exit:
On Error Resume Next
rst.Close
Set rst = Nothing
Application.Echo True
Exit Function
DelCurrentRec_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & _
") in procedure DelCurrentRec of Module modRefresh"
GoTo DelCurrentRec_Exit
End Function
Thanks for your help!