Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 30th, 2006, 12:02 PM
Authorized User
 
Join Date: Oct 2003
Posts: 25
Thanks: 1
Thanked 0 Times in 0 Posts
Default Error 2001 You canceled the previous operation

I have done similar stuff a zillion times and when I get this error it usually means I've misspelled something. The following code produces the error.

Private Sub UnitsOrdered_AfterUpdate()
Dim vID As Integer
vID = Me![ProductID]

Me![UnitPrice] = DLookup("[UnitPrice]", "Products", "[ProductID] = vID")

End Sub
If I plug in Me![ProductID] for vID, I also get the error.
If I plug in an actual ID number, such as 1002, it works.

Anyone have any ideas.

Thanks,
Ray

 
Old December 2nd, 2006, 12:42 PM
Authorized User
 
Join Date: Jan 2006
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try:
Me![UnitPrice] = DLookup("[UnitPrice]", "Products", "[ProductID] =" & vID )


HTH RuralGuy (RG for short) acXP WinXP Pro
 
Old December 5th, 2006, 09:17 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Me.UnitPrice = Nz(DLookup("[UnitPrice]", "Products", "[ProductID] = " & Me.vID), 0)

If vID is a number, or

Me.UnitPrice = Nz(DLookup("[UnitPrice]", "Products", "[ProductID] = '" & Me.vID & "'"), 0)

if vID is a string.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old December 8th, 2006, 03:00 PM
Authorized User
 
Join Date: Oct 2003
Posts: 25
Thanks: 1
Thanked 0 Times in 0 Posts
Default

RG & Greg ..... Thanks for the help. Problem solved.

Ray






Similar Threads
Thread Thread Starter Forum Replies Last Post
Corrupt DB - You cancelled the previous operation timmaher Access 8 June 5th, 2008 05:12 AM
Another Runtime 2001 Error jladder Access VBA 5 May 25th, 2007 05:22 PM
"you canceled the previous operation" error Totenkopf Access VBA 2 June 14th, 2006 02:48 PM
you canceled the previous operation lizhaskin Access 1 July 19th, 2005 12:36 PM
Error 2001: You canceled the previous operation RayL Access VBA 3 May 27th, 2005 07:40 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.