Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cancelled operation error?

Status
Not open for further replies.

ProgramError

Programmer
Mar 2, 2005
1,027
GB
Can anyone explain why I get an error "You cancelled the previous operation" when I run this code
Code:
intInput = InputBox("Enter Request Number", "Program request")
' first check if number is already in the list
temp = DLookup("oddnends", "OARequests", "[progno] = " & intInput)
or
Code:
intInput = InputBox("Enter Request Number", "Program request")
' first check if number is already in the list
temp = DLookup("oddnends", "OARequests", "[progno] = '" & intInput & "'")


Ian Mayor (UK)
Program Error
Always make your words sweet and nice. Because you never know when you may have to eat them.
 
Does the OARequests Table/query really have two fields named oddnends and progno ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
yes

oarequests is a table.
the form is based on this table.
the form is filtered using ...

Private Sub Form_Close()
Me.FilterOn = False
End Sub
and
Private Sub Form_Load()
Me.FilterOn = True
End Sub

The form is displays a list of records which are intended to be printed.
This list is dynamic and should be capable of adding to or deleting records to print without actually deleting the original record (I use the oddnends field for this).
A button on the form opens a inputbox requesting a number.
The intention is to find the record coresponding to that number (progno) and setting or unsetting the oddsnends field which allows to record to be displayed or not when 'filteron' is true. I tried using a query for the form but his prevented me from adding or deleting records in the list.
I have also tried using a separate table for the list, copying the relevent information from the main table but this cause other complications. So this seems the easiest method.

I hope this explains it in a little more detail.


Ian Mayor (UK)
Program Error
Always make your words sweet and nice. Because you never know when you may have to eat them.
 
G'day Ian

oarequests is a table...the form is based on this table...using a query...prevented me from adding or deleting records

Are you linking other tables in the query? Just wondering why you can't add records...

As for the error, have you stepped through the code to see if it occurs after the input box, or after the DLookup?

Frankly, it's hard to see either raising that error. Maybe if you can pin down just when it occurs it might shed some light?

There's always one other possibility - the db has some corruption. Often this can be fixed if caught quickly. The best way seems to be to decompile the code, then recompile, and do a repair & compact.

Max Hugen
Australia
 
Hi Max thanks for the reply.

Yes, there were relationships in the query, that's why I'm trying the table with filter on/off method here.

The error occurs when it tries to execute the dlookup statement.

I've checked the db and maintain a compact and repair routine whenever the database is closed.

Ian Mayor (UK)
Program Error
Always make your words sweet and nice. Because you never know when you may have to eat them.
 
G'day Ian

I notice that you are passing intInput as a string in your DLookup... shouldn't it be:

Code:
temp = DLookup("oddnends", "OARequests", "progno=" & intInput)

As for the non-updateable query, have you tried creating a subquery which contains all the tables apart from the table you need to be able to edit, then link this subquery to the main table in the main query?



Max Hugen
Australia
 
How are ya ProgramError . . .

The error you quoted . . .
ProgramError said:
[blue]"You cancelled the previous operation"[/blue]
. . . is typical of what you'd get if you cancelled a method, like setting the [blue]Cancel[/blue] arguement to [blue]true[/blue] in the [blue]On Open[/blue] event of a form or report. It just doesn't jive with [blue]DLookup[/blue] which is causing the confusion. I'm betting the error is somewhere else and just happens to land on that line of code.

Getting to the query (which you need to filter on oddnends), although its not directly updateable thru the form doesn't mean you can't [blue]update thru SQL or Recordset[/blue], espcially since your hunting for [blue]existing records![/blue] I'm thinking something like:
Code:
[blue]Public Sub AddPrintRec()
   Dim db As DAO.Database, rst As DAO.Recordset
   Dim SQL As String, intInput
   
   intInput = InputBox("Enter Request Number", "Program request")
   
   If IsNumeric(intInput) Then
      intInput = Val(intInput)
      
      Set db = CurrentDb
      Set rst = db.OpenRecordset("OARequests", dbOpenDynaset)
   
      If rst.BOF Then
         MsgBox "No Records! . . . Can't Continue!"
      Else
         rst.FindFirst "[progno] = " & intInput
         
         If rst.NoMatch Then
            MsgBox "Request Number '" & intInput & "' Not Found!"
         Else
            rst.AddNew
            rst!oddnends = True [green]'I'm guessing here![/green]
            rst.Update
            [b]Me.Requery[/b] [green]'Show the record[/green]
         End If
      End If
   Else
      MsgBox "Your entry was not Numeric! . . . try again!"
   End If
End Sub[/blue]
If [blue]oddnends[/blue] is a boolean field then its easy enough to add/delete without changing/loosing any data by updating [blue]true or false[/blue].

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top