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
robfAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

shanesuebsahakarnCommented:
AbsolutePosition only applies to Snapshot type recordsets - what type is your form's recordset?
0
robfAuthor Commented:
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]))
0
robfAuthor Commented:
Is there a way to test for deleted record?
0
Arthur_WoodCommented:
try this change to your code:


Private mblnDeleteing as Boolean

Private Sub cmdDelete_Click()
On Error GoTo Err_cmdDelete_Click

    ' Delete the item
    mblnDeleteing = Trye
    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
    mblnDeleteing = False
    ** !!!! 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.
    If Not  mblnDeleteing  Then  ' only execute the next line when NOT deleting Records
         HandleUnboundControls   ' This code raises error
    End if
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


AW
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.