Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SOS !!!! Dlookup and error 2001 (Canceled prev. oper)

Status
Not open for further replies.

Theseekers

Technical User
Jul 22, 2004
118
US
Hi folk,

I ran into this little problem and could not see the light at the end of the tunnel and may be some kind soul here lend me lighter so I can get out of this.... :) :)

Here is my problem:

I have a data entry form that was called from another the form. Upon open this data entry form, I grabbed the id from the calling form and pop it in a bounded control text box (no problem). I would like also to use this value to get extra data from another table. So I use the DLOOKup function to get the extra data. Somehow my code give me the famous RT 2001 - you canceled previous operation..

Here is my code (and I put it in the Form open event)

Code:
  If (not(isnull(me.openArgs)) then
     me.TxtSDANID.defaultvalue = cint(me.openargs)
     me.txtage = dlookup("Age", "TblSubject", "SubjID = " & me.TxtSDANID)   <========  The bus stops here... HELP !!!

  endif

Can anyone offer me an explaination as to the above statement produce this RT error????

As always Thank you for your time and input.
 
Hi
You have set a default value, but I do not think me.TxtSDANID is equal to anything yet. How about:
me.txtage = dlookup("Age", "TblSubject", "SubjID = " & cint(me.openargs))
I have not tested this.
 
Try to move this code from the Open event to the Load event procedure, as when the form is not yet loaded it's unsafe to reference any control ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
WOW..... Thanks for the speeeeediest response. I certainly will try it now and get back to the forum pronto...

Thanks again
 
Hi Remou & PHV,

I tried yours suggestion (both) but still get this error. Any other thought????.

BTW Remou, When I set the control to the openarg; it did put in the correct value for the id, but your ways is much "kooooler"...

Thanks again
 
Hi TheSeeker
I have tried to reproduce the error you are getting, but cannot. Or at least, cannot when I put the code in the Load Event as PHV recommends (says really, PHV always recommends the right thing :))
This:
If (not(isnull(me.openArgs)) then
Did give an error, I had to change it to:
If not isnull(me.openArgs) then

 
Yeap, you can be sure that everything the PVH put out -- IT ROCKS!!!!..

Thanks for pointing out on the if statement. I did have an extra ( in the post - my typo...)

No the if statement runs fine (of course with not isnull...)

Hummmmm strange strange... you don't have the problem with the code and I do.....????????

I have try to put the dlookup directly on the control itself (exactly like I did on the vba code with exception of the variable before the =) and it works fine.

it seems to me that whenever i try to assign the value of the dlookup() to a control (in this case unbound); I get this error....

Thanks for your input


 
Solved the problem!!!!!

I mistype a field name in the criteria of the DLOOKUP. Found it, fixed it, and worked like a dream.

Thanks for all your help


My .02

Ask for extra pair of eyes and you will see better.

Thanks again and til next time, my friends
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top