Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
| Search | Today's Posts | Mark Forums Read
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 May 23rd, 2005, 07:58 AM
Authorized User
 
Join Date: Oct 2003
Location: , , .
Posts: 25
Thanks: 1
Thanked 0 Times in 0 Posts
Default Error 2001: You canceled the previous operation

The following code is connected to the After-Update event of a Text Box. When the code runs, I get an Error 2001: You canceled the previous operation. This happens only for vSeries, not for vMfgDate. Does anyone have any idea why this is happening?

Thanks,

Ray


Private Sub SN_AfterUpdate()
Dim vMSG As String
Dim vSeries, vSN As Variant
Dim vMfgDate As Date


vSeries = Nz(DLookup("[PumpType]", "Test Stand Data", "[SerialNumber]=Form![SN]"), 0)
vMfgDate = Nz(DLookup("[Date]", "Test Stand Data", "[SerialNumber]=form![SN]"), 0)

 
Old May 24th, 2005, 07:50 AM
Friend of Wrox
 
Join Date: Nov 2004
Location: Seattle, WA, .
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

This happens to me all the time! Your DLookup has invalid syntax.

Not sure what your field names are and all, but try this:
Code:
vSeries = Nz(DLookup("[PumpType]", "[Test Stand Data]", "[SerialNumber]=" Me.SN), 0)
vMfgDate = Nz(DLookup("[Date]", "[Test Stand Data]", "[SerialNumber]=" & Me.SN), 0)
Note the brackets [] around the table name. That may be the only problem.

If [SerialNumber] is a Text field, use:
Code:
vSeries = Nz(DLookup("[PumpType]", "[Test Stand Data]", "[SerialNumber]='" Me.SN & "'"), 0)
vMfgDate = Nz(DLookup("[Date]", "[Test Stand Data]", "[SerialNumber]='" & Me.SN & "'"), 0)
Also, since Date is a reserved word in VBA, I would rename the field [Date] in your table. And make sure you are using correct field names. And for future reference you should, wherever possible, avoid spaces in the name of any object. If [Test Stand Data] didn't have spaces you may not have had an error... and I wouldn't be writing this and admonishing you for your naming conventions. :D

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org
 
Old May 27th, 2005, 06:52 AM
Authorized User
 
Join Date: Oct 2003
Location: , , .
Posts: 25
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Randall .... thanks for your reply. I tried your code, but that didn't work either. I understand your concern about naming conventions and I usually try to avoid the things you mentioned. I didn't design this particular table, I've linked to another persons database to grab this data so I'm kind of stuck with it. :(
One thing that confuses me is that the second line of code works and the syntax is the same. Thanks again for taking the time to answer my call for help.

Ray

 
Old May 27th, 2005, 07:40 AM
Friend of Wrox
 
Join Date: Nov 2004
Location: Seattle, WA, .
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

Possibilities:
  • [PumpType] is not the field name in [Test Stand Data], this would cause the original error.
  • Change your "Dim vSeries, vSN As Variant" to two separate Dim statements.
  • [PumpType] is returning the correct value but you don't trust it.




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
Error 2001 You canceled the previous operation RayL Access VBA 3 December 8th, 2006 03:00 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





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