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 July 3rd, 2004, 11:31 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 451
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ben Horne
Default How Can I Keep This Error Message From Popping Up

Hi all,

Right now, I've got a fully-functioning Queries Dialog Box except for one problem. Whenever I cancel out of a parameter query, I get the following error.

Run time error '2001':
You canceled the previous operation

This is the code that gets highlighted when the VBA editor opens(This is after I click on the Debug button)

Private Sub DisplayQuery_Click()
    'Open the selected query in Datasheet View
    DoCmd.OpenQuery [QueryList Control], acViewNormal
End Sub


Is there any way to keep the above-mentioned error message from EVER popping up again in the future?

Thanks in advance,



Ben Horne
Madison Area Technical College - Truax
3550 Anderson Street
Madison, Wisconsin 53704-2599


-------------------------
http://community.webshots.com/user/valerian114

"There are two kinds of people in the world: Those who claim to be Flash junkies and those who actually are Flash junkies"
__________________
Ben Horne
-------------------------
I don\'t want to sound like I haven\'t made any mistakes. I\'m confident I have.

Most likely using FireFox and concocting my next Macromedia Flash project
Snibworks Forums Moderator

Welcome to the New Age
 
Old July 4th, 2004, 12:29 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Hi Ben,

Run time error '2001' often means you are dealing with a corrupt object. You could try testing your query dialog in a new .mdb, though some other object or module may be the culprit, and will simply have to be re-created.

In the mean time, you could see what impact simply ignoring the error might have:

Private Sub DisplayQuery_Click()
   On Error GoTo ErrorHandler

   'Open the selected query in Datasheet View
    DoCmd.OpenQuery [QueryList Control], acViewNormal

ErrorHandlerExit:
   Exit Sub

ErrorHandler:
   If Err.Number = 2001 Then
      Resume Next
   Else
      MsgBox "Error No: " & Err.Number & "; Description: "
      Resume ErrorHandlerExit
   End If
End Sub

HTH,

Bob

 
Old July 4th, 2004, 12:35 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

oops...forgot the Description property in the error handler:

MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description

 
Old July 4th, 2004, 12:37 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 451
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ben Horne
Default

Bob,

Thank you so much for the help:), The code you added on to mine helped out a lot. I am not seeing that error message anymore.

Thanks again

Ben Horne
Madison Area Technical College - Truax
3550 Anderson Street
Madison, Wisconsin 53704-2599


-------------------------
http://community.webshots.com/user/valerian114

"There are two kinds of people in the world: Those who claim to be Flash junkies and those who actually are Flash junkies"
 
Old July 4th, 2004, 12:57 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

You're welcome, Ben. Glad it worked for ya'.

Bob

 
Old March 24th, 2009, 11:14 AM
Registered User
 
Join Date: Mar 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error code 2001

Bob, I was also receiving error code 2001, and tried your suggestion, but then received error code 3078 (which is basically similar to 2001, from what I have seen elsewhere in forums). It seems to think [Date] is a table, but it should be a field/expression from the DMax help in Access. Below is my code.

Dim DateX As Date
Dim Msg

Sub test1()
On Error GoTo ErrorHandler
DateX = DMax("[Date]", "tblWellMaintenanceLogbook", "[Combo34] =" _
& Forms!frmWellMaintenance!Combo34)

Msg = DateX
ErrorHandlerExit:
Exit Sub
ErrorHandler:
If Err.Number = 2001 Then
Resume Next
Else
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume ErrorHandlerExit
End If
End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the error message for a 500 server error? chobo2 C# 2005 1 May 4th, 2008 03:11 AM
Where does the error message go? Wei Wang BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 March 13th, 2006 02:03 PM
Error Message alannoble26 Excel VBA 4 November 25th, 2005 11:20 AM
error message. Tasha Access VBA 2 August 11th, 2004 11:07 PM
Help with Error message mariakovacs Classic ASP Databases 3 October 10th, 2003 03:59 PM





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