"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]")
nussedogAsked:
Who is Participating?
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Connect With a Mentor 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.
0
 
mbizupCommented:
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] & "'")
0
 
Jeffrey CoachmanMIS LiasonCommented:
nussedog,

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

JeffCoachman

0
 
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"
0
 
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.
0
All Courses

From novice to tech pro — start learning today.