Link to home
Start Free TrialLog in
Avatar of robf
robf

asked on

Problem deleting record with unbound controls that are updated by the "on current" event

I used the access wizard to place a delete record button on the form.  It worked fine until I added an unbound control to the form that I updated via the on current event.

I modified the cmdDelete button's event as follows:
 *** The error I get is Runtime Error 3167.  The record is deleted  ****
Private Sub cmdDelete_Click()
On Error GoTo Err_cmdDelete_Click

    ' Delete the item
    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
    ** !!!! ON CURRENT EVENT FIRES HERE !!! CAUSING AN ERROR **

' rest of code cut for brevity reasons
End Sub

' Here is my On Current event
Private Sub Form_Current()
    ' Used for navigation buttons
    acbHandleCurrent Me ' This code executes fine.
    HandleUnboundControls   ' This code raises error
 
End Sub

' Update any unbound controls on the form
Private Sub HandleUnboundControls()
    ** Code below raises error at the evaluation of the if statement when I first read Recordset.absoluteposition
    ** if I press continue the code contines without further error.  Any thoughts???
    If (Recordset.AbsolutePosition = -1) Then
        cmbItem = Null
        cmbDescription = Null
    Else
        cmbItem = Recordset!ITEM
        cmbDescription = Recordset!DESCRIPTION
    End If
   
 End Sub
Avatar of shanesuebsahakarn
shanesuebsahakarn
Flag of United Kingdom of Great Britain and Northern Ireland image

AbsolutePosition only applies to Snapshot type recordsets - what type is your form's recordset?
Avatar of robf
robf

ASKER

It's an access query called "Catalog Extended" that contains fields from a table called "Catalog" such as ITEM, and [MATERIAL COST] as well as some calculated fields such as [UNIT PRICE] which is (([MATERIAL MARKUP]+[LABOR MARKUP]))
Avatar of robf

ASKER

Is there a way to test for deleted record?
ASKER CERTIFIED SOLUTION
Avatar of Arthur_Wood
Arthur_Wood
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial