requery causes error in MDE but not MDB

cpberg1

It's always rainy here
Local time
Today, 11:15
Joined
Jan 21, 2012
Messages
79
Code:
Private Sub DeleteRecord_Click()


On Error GoTo Err_DeleteRecord_Click
Dim msgboxanswer As Integer

msgboxanswer = MsgBox("Are you sure you want to Delete this Record?", vbOKCancel)

If msgboxanswer = 1 Then


    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
    DoCmd.Requery "CancellationList"
    
End If

Exit_DeleteRecord_Click:
    Exit Sub

Err_DeleteRecord_Click:
    MsgBox Err.Description
    Resume Exit_DeleteRecord_Click
    
End Sub

Gives error on DoCmd.Requery "CancellationList". Works just fine in my MDB, complies fine, create MDE normal. when I click the button from my MDE I get a "There is no field named [CancellationList] in the current record.

I'm so confused! First time I've seen the error created only in MDE. Tried renaming the control with no success, still get the same error. Any other ideas to try?
 
What is "CancellationList"

A Form, a SubForm, a Query.
 
It is a list box on a Single form.
 
Nominate the control with its full name and use its requery method.
Me.CancellationList.Requery

This is the modern object oriented syntax.

Also note that DoMenuItem has been deprecated syntax since the turn of the century. You should be using methods of the DoCmd object.
 
nominate the control with its full name and use its requery method.
Me.cancellationlist.requery

this is the modern object oriented syntax.

Also note that domenuitem has been deprecated syntax since the turn of the century. You should be using methods of the docmd object.

^^^^^^^^ +1 ^^^^^^^^^
 
Nominate the control with its full name and use its requery method.
Me.CancellationList.Requery

This is the modern object oriented syntax.

Also note that DoMenuItem has been deprecated syntax since the turn of the century. You should be using methods of the DoCmd object.


Thanks all! I'm pretty sure most of the database examples I have been teaching myself with are turn of the century-ish creation dates, so that explains some of the issue.

I'll give it a go at work tomorrow and report back.
 
Thanks all! I'm pretty sure most of the database examples I have been teaching myself with are turn of the century-ish creation dates, so that explains some of the issue.

Yes, you need to watch out for pages that contain code for older versions of Access. New functionality was added in 2003 and supplanted quite of lot of complex code.

I remember coming across procedures with hundreds of lines to do something I had working in a handful of lines in A2003.
 

Users who are viewing this thread

Back
Top Bottom