Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old November 13th, 2005, 01:00 AM
John Martin
Guest
 
Posts: n/a
Default 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
  #2  
Old November 13th, 2005, 01:00 AM
WindAndWaves
Guest
 
Posts: n/a
Default Re: What operation have I cancelled?

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


  #3  
Old November 13th, 2005, 01:00 AM
PC Datasheet
Guest
 
Posts: n/a
Default Re: What operation have I cancelled?

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
resource@pcdatasheet.com
www.pcdatasheet.com


"John Martin" <jhmwine@aol.com> wrote in message
news:20040620181647.15941.00000226@mb-m21.aol.com...[color=blue]
> 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.[/color]
This[color=blue]
> 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[/color]


  #4  
Old November 13th, 2005, 01:00 AM
John Martin
Guest
 
Posts: n/a
Default Re: What operation have I cancelled?

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

  #5  
Old November 13th, 2005, 01:00 AM
WindAndWaves
Guest
 
Posts: n/a
Default Re: What operation have I cancelled?

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


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles