"You cancelled the previous operation error" MS ACCESS

Help!  I have no idea what the hell is going on.
I copied a main form "Turnin Maint" as "Turnin Entry", and a subform "TurninDetail Maint" as "TurninDetail Entry". The following code works fine in the "Turnin Maint" form, but will not work in 'new' "TurnIn Entry" form. For reference I have included original code as well as 'new' code:
Current code line from "Turnin Entry" form:
[Rate Per Sig] = DLookup("[Fee Per Sig]", "Petitions", "[Petition Code]=Forms![TurnIn Entry]![TurninDetail Entry].Form![Petition Code]")
Original Code line from "Turnin Maint" form:
[Rate Per Sig] = DLookup("[Fee Per Sig]", "Petitions", "[Petition Code]=Forms![TurnIn Maint]![TurnInDetail Maint].Form![Petition Code]")
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.

That error in a DLookup statement generally means that a field or table name is unrecognized (typo or wrong name).  It can also mean that an error such as a type mismatch or other error has been encountered.  

In this case, you need to seperate out the form reference using ampersands.

Also, What is the data type of Petition Code?  If it is Text, use single quote delimiters.

Numeric petition Code:
[Rate Per Sig] = DLookup("[Fee Per Sig]", "Petitions", "[Petition Code]=" & Forms![TurnIn Entry]![TurninDetail Entry].Form![Petition Code])

Text Petition Code:
[Rate Per Sig] = DLookup("[Fee Per Sig]", "Petitions", "[Petition Code]='" & Forms![TurnIn Entry]![TurninDetail Entry].Form![Petition Code] & "'")
Jeffrey CoachmanMIS LiasonCommented:

I'm with mbizup, check all of your object names for mis-spellings first.

Also you did not say where, when, or under what circumstances the code is running.
Perhaps you activate this code before the record is updated (saved),... in this case the dlookup might not find the value, because the record has not yet been saved.
Try adding an explicit save, before your code, to whatever form contains the "Petition code".
Something like this:
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
    [Rate Per Sig] = DLookup("[Fee Per Sig]", "Petitions", "[Petition Code]=Forms![TurnIn Entry]![TurninDetail Entry].Form![Petition Code]")

Couldn't hurt to try?

Hope this helps as well


Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Are you absolutely sure that the Subform OBJECT on your main form is named TurnInDetail Maint? Note that this would NOT the name of the form being used as a subform, but instead the name of the Subform Object being used on the mainform.

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
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Sorry, got that backwards ... your Subform OBJECT on your "new" form should be named "TurninDetail Entry"
nussedogAuthor Commented:
Others were on the right trail but you got it exactly. When I copied and pasted the form, the form object retained the old form name, which was causing the problem.
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.