473,322 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

What operation have I cancelled?

I am making my first attempt at a project using VBA and have hit a problem. I
can find nothing to help in any book. My code is generating a message "Runtime
error 2001 You canceled the previous operation."

I created a relatively simple form, which allows the user to view and add
details of patients. I put a filter option control on the form so that the
patients could be filtered to those allocated to a chosen member of staff. This
worked perfectly.

Afterwards, I created various reports and, finally, another form to select the
particular report required with another filter option control to limit the
selected report to the patients of a particular member of staff. This works as
expected. I stopped for the day, well content.

The next time I opened the project, I went to the first form and immediately
received the error message mentioned when I tried to impose the filter to the
chosen member of staff. What operation have I cancelled? At this stage, I have
not run any other code. Only removing the second form and its code makes the
first form work again without generating the error.

It seems that there is no "help" available from the program.
I would appreciate any assistance.

John Martin
Nov 13 '05 #1
4 3062
I often get this error message when I use an aggregate function (e.g.
dcount, dlookup, etc....)

It really does not make sense. So the error message will not give you to
many clues.

Therefore, you need to find out when it happens. Do you know how to debug
code (do you have any???).

- Nicolaas
Nov 13 '05 #2
Hi John,

The cause of this problem is that you execute code to open the report but jump
to some other code before the report opens. Typically this other code is in the
OnOpen event of the report where you cancel opening the report. The cure to the
problem is to put the following line of code in the first code where you open
the report. Put it as the first line of code in your procedure:
On Error Resume Next

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"John Martin" <jh*****@aol.com> wrote in message
news:20***************************@mb-m21.aol.com...
I am making my first attempt at a project using VBA and have hit a problem. I
can find nothing to help in any book. My code is generating a message "Runtime
error 2001 You canceled the previous operation."

I created a relatively simple form, which allows the user to view and add
details of patients. I put a filter option control on the form so that the
patients could be filtered to those allocated to a chosen member of staff. This worked perfectly.

Afterwards, I created various reports and, finally, another form to select the
particular report required with another filter option control to limit the
selected report to the patients of a particular member of staff. This works as
expected. I stopped for the day, well content.

The next time I opened the project, I went to the first form and immediately
received the error message mentioned when I tried to impose the filter to the
chosen member of staff. What operation have I cancelled? At this stage, I have
not run any other code. Only removing the second form and its code makes the
first form work again without generating the error.

It seems that there is no "help" available from the program.
I would appreciate any assistance.

John Martin

Nov 13 '05 #3
There's no such function in my code. I do have some. Please tell me what's
wrong with this:

Option Compare Database
Option Explicit
Dim pstrReportName As String
Dim pstrFilter As String

Private Sub ExitReportFilterButton_Click()
On Error GoTo Err_ExitReportFilterButton_Click

DoCmd.Close acForm, "Report Filter Form"

Exit_ExitReportFilterButton_Click:
Exit Sub

Err_ExitReportFilterButton_Click:
MsgBox Err.Description
Resume Exit_ExitReportFilterButton_Click

End Sub

Private Sub ProceedReportButton_Click()
' On Error GoTo Err_ProceedReportButton_Click
On Error Resume Next

DoCmd.OpenReport pstrReportName, acViewPreview, , pstrFilter
DoCmd.Close acForm, "Report Filter Form"

Exit_ProceedReportButton_Click:
Exit Sub

Err_ProceedReportButton_Click:
MsgBox Err.Description
Resume Exit_ProceedReportButton_Click

End Sub

Private Sub ReportSelecterOption_BeforeUpdate(Cancel As Integer)
On Error Resume Next

Select Case ReportSelecterOption
Case 1
pstrReportName = "Patients (Alphabetical)"
Case 2
pstrReportName = "Patients (By Case Open for)"
Case 3
pstrReportName = "Patients (By case open to & case open for)"
Case 4
pstrReportName = "Patients by registration date"
Case 5
pstrReportName = "Patients (by case open to)"
End Select
End Sub
Private Sub ReportFilterOption_BeforeUpdate(Cancel As Integer)
On Error Resume Next
Select Case ReportFilterOption
Case 2 'KM selected
pstrFilter = "[case open to] = 2"
Case 3 'CW selected
pstrFilter = "[case open to] = 3"
Case 4 'HvL selected
pstrFilter = "[case open to] = 1"
Case 5 'Unallocated selected
pstrFilter = "[case open to] = 4"
Case Else 'no value for intFilter if All selected
pstrFilter = ""
End Select
End Sub

Nov 13 '05 #4
I had a look through your code.

It looks fine at first, but it definitely could have many problems.

The way to solve a problem like this is to put in some breakpoints to work
out where things go wrong.

Also put a ' before each error handler. In that way, your code will break
when the error occurs.

Once you are satisfied that it works then you take the apostrophes back out.

Once you work out where the problem occurs, you can put in a few breakpoints
and see, for example, what values your variables have (move your mouse over
them).

Let me know how you get on.

- Nicolaas
Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Vic | last post by:
Dear All, I found this code snippet on this list (taken from a nice webpage of a courteous fellow), which I used to filter a form on a combo box. I wanted to repeat the same code to have an...
2
by: Richard Hollenbeck | last post by:
I got this: "Error 2001 You cancelled the previous operation" with this: Private Sub courseCode_GotFocus() Dim myDLookupResults As String myDLookupResults = DLookup("courseID", "courses",...
2
by: John A. | last post by:
I've received this error several times, and have only been able to get around it by deleting the offending form(s) and importing them from backup - Here's the sequence: 1. I'm editing a form or...
2
by: jeffrod444 | last post by:
Hi, I've been having problems getting my forms to work correctly. If seen other threads addressing this issue, however, these are not working for me. The short of my problem is this. I am trying to...
6
by: allyn44 | last post by:
HI--what I am trying to do is 2 things: 1. Open a form in either data entry mode or edit mode depending on what task the user is performing 2. Cancel events tied to fields on the form if I am in...
2
by: Edward | last post by:
For reporting purposes I use Crystal Reports. The user can select a printer from a dropdownlist. I set the printer with: PrintOptions.PrinterName = @"\\SERVERNAME\" +...
0
by: sst1234 | last post by:
error operation has been cancelled by user regards
1
by: nw2wa | last post by:
We have two database files not working correctly when attempting to view the Detailed Invoice screen. The results are not the same but neither will work. The original database is saved on a shared...
4
by: Phil Stanton | last post by:
I am opening a report (in Preview) from a menu system I use the following code if there is no data in a report Private Sub Report_NoData(Cancel As Integer) MsgBox "There are no errors in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.