error 2001: you canceled the operation

thedialyzer

New member
Local time
Today, 12:55
Joined
Jun 17, 2011
Messages
2
Hi

I have a command button on a form which runs an append query. If the user "cancels" and does not input any data, the following error occurs:

"Error 2001: You canceled the previous operation"

Here is the code:

Dim stDocName As String
stDocName = "PD_new_patient_append"
DoCmd.SetWarnings warningsoff
DoCmd.OpenQuery stDocName, acNormal, acEdit
MsgBox "Please select your patient from the 'Select Existing PD Patient to Update' box."
DoCmd.Requery
Me.PatList.Requery
DoCmd.SetWarnings warningson

I am using Access 2003 for compatibility reasons. Any suggestions are welcome.
 
DoCmd.SetWarnings warningsoff

DoCmd.SetWarnings warningson
Notice that none of the letters in warningsoff and warningson have been capitalized? If these were the correct arguments Access' Intellisense would have done that for you when you left the line of code. You should have used

DoCmd.SetWarnings False

and

DoCmd.SetWarnings True

Linq ;0)>
 
Thank you. Worked like a charm.
 

Users who are viewing this thread

Back
Top Bottom