Wrox Programmer Forums
|
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 October 2nd, 2006, 01:42 PM
Registered User
 
Join Date: Oct 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to kcolli20 Send a message via Yahoo to kcolli20
Default Run-time error 2001

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)
 sub_View_ContAccrl.Form.Filter = dynSQL
  sub_View_ContAccrl.Form.FilterOn = True

  SQL = "SELECT SUM(View_ContAccrl.hours) AS TotHours, Sum(View_ContAccrl.cost) AS TotCost FROM View_ContAccrl "
  SQL = SQL & " WHERE " & dynSQL & ";"

  Set rs = CurrentDb.OpenRecordset(SQL, dbOpenSnapshot)

  If rs.RecordCount > 1 Then
      MsgBox "Unable to calculate sums"

  Else
      If IsNull(rs.Fields("TotHours")) Then
          Me.txtTotCost = Format(0, "$#,##0.00")
      Else
          Me.txtTotCost = Format(rs.Fields("TotCost"), "$#,##0.00")
      End If


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

Thanks in advance

Kimberley L. Collins
 
Old October 3rd, 2006, 07:00 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I am not sure what a "fully-functioning Queries Dialog Box" is. My suggestion is to cancel out of the query before you get to the query. Why are you cancelling out of a query in the middle of it? Pass values to the form to populate the form, and then package the values for the parameters and run the query on a seperate event.

The short answer is that you can't prevent these application errors from happening without trapping them properly. That would require this sort of coding:

On Error Resume Next

'some processing

'Check for error
If Err <> 0 Then
   'do something
   'Exit Sub perhaps
End If
'reset err
Err.Clear

'some more processing

'check for a new error etc

Does this help?


mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Query Error & Run-Time Error 3022 DavidWE Access 1 July 31st, 2008 11:17 AM
run-time error(s) Chacko C++ Programming 0 March 4th, 2007 02:28 PM
Run-time error 2001 ebburks Access 1 June 8th, 2006 06:56 AM
Run Time Error JBond Access VBA 0 May 27th, 2004 09:50 AM
RUN-TIME ERROR compcad Beginning VB 6 2 May 21st, 2004 02:01 AM





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