How do I overcome the "Property not found" error when BeforeUpdate is cancelled in Access 2007?

I recently upgraded to Microsoft Access 2007 but I still use the old file format (Access 2000-2003). My code was working perfectly with Access 2003 but now I get an error saying "Property not found". I can't figure out what property it is looking for.

Could someone give me some tips?

Thanks,
camoh
Private Sub QtyOrdered_AfterUpdate()
On Error GoTo Err_QtyOrdered_AfterUpdate:
 
Me.Refresh
 
Dim rst1 As Recordset
Dim rst2 As Recordset
Dim dbs As Database
 
Set dbs = CurrentDb
Set rst1 = dbs.OpenRecordset("Products", dbOpenDynaset)
Set rst2 = dbs.OpenRecordset("QryQtyOnHand", dbOpenDynaset)
 
Do Until rst1.EOF
    With rst2
        .FindFirst "[ProductID]= '" & rst1![ProductID] & "'"
        If .NoMatch Then
            rst1.Edit
            rst1!QtyOnHand = 0
            rst1!OpenOrders = 0
            rst1.Update
        Else
            rst1.Edit
            rst1!QtyOnHand = rst2!OnHand
            rst1!OpenOrders = rst2!OnOrder
            rst1.Update
        End If
    End With
rst1.MoveNext
Loop
 
rst1.Close
rst2.Close
 
Me.Refresh
 
 
Exit_QtyOrdered_AfterUpdate:
    Exit Sub
 
Err_QtyOrdered_AfterUpdate:
    MsgBox Err.Description
    Resume Exit_QtyOrdered_AfterUpdate
    
End Sub
 
Private Sub QtyOrdered_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_QtyOrdered_BeforeUpdate:
 
Dim Msg, Style, Response
 
Msg = "Are you sure you want to change the ORIGINAL order quantity?"
Style = vbYesNo + vbDefaultButton2 + vbExclamation 'Define buttons.
 
If QtyOrdered.OldValue <> QtyOrdered.Value Then
    Response = MsgBox(Msg, Style, "Attention!")
    If Response = vbNo Then
        QtyOrdered.Undo
        Cancel = True '****When I run this line, I get an error.**** 
    End If
End If
 
Exit_QtyOrdered_BeforeUpdate:
    Exit Sub
 
Err_QtyOrdered_BeforeUpdate:
    MsgBox Err.Description
    Resume Exit_QtyOrdered_BeforeUpdate
    
End Sub

Open in new window

camohAsked:
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.

Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Can you perform step-through debugging on this, and then identify that exact line that is throwing the error?
0
camohAuthor Commented:
I can put a breakpoint into the events and step thru them but no error message shows up until it appears to be finished running code.

To be exact, the message pops up after line 64 is run but it happens only if line 59 is run.
0
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
>Private Sub QtyOrdered_AfterUpdate()
>Cancel = True '****When I run this line, I get an error.****

The AfterUpdate event does not have a Cancel parameter.  
AfterUpdate = After you update = it's already committed, so you can't change it.

Move your code into the BeforeUpdate event.

Private Sub QtyOrdered_BeforeUpdate(Cancel as Integer)   '<--- looky here, a Cancel parameter
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

camohAuthor Commented:
>Move your code into the BeforeUpdate event.
It is only in the BeforeUpdate event already.

Sorry I might have made it confusing by pasting both the before and after update events in one snippet.
0
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
I see, you are correct.

Just a guess, if you are using .Undo, then there may be nothing to cancel, hence the error message.

QtyOrdered.Undo
Cancel = True

Try removing the .Undo line.  If that doesn't work, remove both and throw in DoCmd.CancelEvent
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
camohAuthor Commented:
Removing the .Undo line did not work.

The following code worked as per modifying your suggestion by replacing only the Cancel = True line
with DoCmd.CancelEvent.

I thought DoCmd.CancelEvent would cancel all previous code in the event but it does not appear to be doing so.

Thank you very much for your help!
camoh
0
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.