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?
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Connect With a Mentor Commented:
Check qryproductsordered to see if it is returning any records OR if it has an error running by iteself.
mx
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
You can also try:

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

mx
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
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 MVP, Access and Data Platform)Commented:
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
All Courses

From novice to tech pro — start learning today.