runtime error 2001 (dsum issue)

i am getting the followign error from the code snippet supplied:

runtime error 2001

you cancelled the previous operation

any help would be very much appreciated
Dim curx As Currency
Dim curv As Currency
 
curx = DSum("[agreedprice]", "qryproductsordered")
curv = DSum("[rentalprice]", "qryproductsordered")
 
Me.Text55.Value = curx
Me.Text58.Value = curv

Open in new window

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

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Check qryproductsordered to see if it is returning any records OR if it has an error running by iteself.
mx
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
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
You can also try:

curx = Nz(DSum("[agreedprice]", "qryproductsordered"))
curv = Nz(DSum("[rentalprice]", "qryproductsordered"))

mx
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Also note that because you have dimmed

Dim curv As Currency

If an attempt to sent curv to Null, that could also cause an Invalid Use of Null error.  So, you need to test for a Null condition.  Sometimes however, that 2001 in this case is because the query itself has an issue.

mx
0
mrBrightsideAuthor Commented:
thanks for your help but i have been a bit silly.....i was using curv = Nz(DSum("[rentalprice]", "qryproductsordered")) and it should have been curv = Nz(DSum("[agreedrental]", "qryproductsordered"))

so i have reworded it and it works fine.....
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
That was basically my suggestion:

"Check qryproductsordered to see if it is returning any records OR if it has an error running by iteself"

mx
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.