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!

Error 2001 - You canceled the previous operation

Status
Not open for further replies.

flaviooooo

Programmer
Feb 24, 2003
496
FR
Hi,

I have a form that's giving me a headache. On top there is a combobox, containing all orders. Now when I select an order, the form would be filled with the data of that order.

Unfortunately, things don't seem to be so simple. I have to select an order up to 4 times before it actually gives me all the data. The other times it gives me the error 2001 - you canceled the previous operation.

The code looks like this:

Private Sub cmbSelectedOrder_AfterUpdate()
On Error GoTo Catch

Dim intParameterFieldNr As Integer
Dim strParameterList As String
Dim rsEnquiry As ADODB.Recordset

Dim cTrL As Control

Try:

If Me.Dirty Then
'Save Record
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
End If

'* Clear the preview screen
O_Preview.Value = Nothing
'* Display the Name of the client
txtSelectedKlant.Value = cmbSleutel.Column(2)
'* Lookup and display the correct record for the selected order
Set rsEnquiry = Me.RecordsetClone


With rsEnquiry
rsEnquiry.Find "OrderID='" & Me.cmbSelectedOrder.Value & "'"
If rsEnquiry.EOF Then
MsgBox "Order bestaat niet.", vbOKOnly + vbExclamation
GoTo finally
Else
Me.Bookmark = rsEnquiry.Bookmark
End If
End With

finally:
Set rsEnquiry = Nothing
Exit Sub
Catch:
moGeneral.HandleError Err.Number, Err.Description, Me.Name & ".cmbSelectedOrder_AfterUpdate"
Resume finally
End Sub


The code gives me the error on line
Me.Bookmark = rsEnquiry.Bookmark


Any ideas what could be the problem?
 
Why don't you just filter the recordset:
Code:
Me.Filter = "[OrderID]='" & Me!cmbSelectedOrder & "'"
Me.FilterOn = True

I love the Try / Catch / Finally construct! That's the first time I've seen anyone use that in classic VB. I thought I was in the .Net forum for a second...

One note, the save method you're using has been retained for backwards compatibility, but uses an Access 95 toolbar command to save. The DoCmd object can do the same thing with less typing (DoCmd is implied):
Code:
RunCommand acCmdSaveRecord

VBSlammer
redinvader3walking.gif

"You just have to know which screws to turn." - Professor Bob
 
Thanks for the help man, it works fine now!

The Try / Catch / Finally construction is pretty cool yeah, I stole this from external employee ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top