error 2001

CJBIRKIN

Drink!
Local time
Today, 14:02
Joined
May 10, 2002
Messages
255
Hello

I've written this in the on click event of a cmd button
when i run it and it gets to get the form load event of the form i'm opening i get an error (2001) "you cancelled the previous operation" at the line Me.RecordSource = OpenArgs

I don't see how this error can be generated as it would require some intervention between me clicking the cmd button and the form opening.

Any ideas??

Chris


Dim stDocName As String
Dim stLinkCriteria As String
Dim StrMsgStr As String
Dim StrSql As String
Dim COMBO1ID As Variant
Dim COMBO5ID As Variant
Dim COMBO7ID As Variant

stDocName = "APPOINTMENT_SPELL_FRM"

If [Forms]![menu_frm]![Combo1] = 0 Then
COMBO1ID = "*"
Else
COMBO1ID = [Forms]![menu_frm]![Combo1]
End If

If IsNull([Forms]![menu_frm]![Combo5]) = True Then
COMBO5ID = "*"
Else
COMBO5ID = [Forms]![menu_frm]![Combo5]
End If

If IsNull([Forms]![menu_frm]![Combo7]) = True Then
COMBO7ID = "*"
Else
COMBO7ID = [Forms]![menu_frm]![Combo7]
End If

StrSql = "SELECT TBL_PATIENT.*, TBL_SPELL.*" _
& "FROM TBL_PATIENT LEFT JOIN TBL_SPELL ON TBL_PATIENT.PMI = TBL_SPELL.PMI_FK " _
& "WHERE (((TBL_SPELL.CASE_TYPE_FK)=" & "'" & COMBO5ID & "'" & ") AND ((TBL_SPELL.OUTCOME_ID_FK)=" & "'" & COMBO7ID & "'" & ") AND ((IIf([OUTCOME_ID_FK]=0,round((DateDiff('d',[APPOINTMENT_DATE],Date())/7),2),'EPISODE CLOSED'))=" & "'" & COMBO1ID & "'" & "));"


DoCmd.OpenForm stDocName, , , , , , StrSql
 
Strangely I don't see a line:

Me.RecordSource = OpenArgs

in your code anywhere.

I did notice that you might want to put a space between the * and the " at the end of this line:

StrSql = "SELECT TBL_PATIENT.*, TBL_SPELL.*" _

As you have it now your StrSql would read:

SELECT TBL_PATIENT.*, TBL_SPELL.*FROM TBL_PATIENT ...
 
Hello

apologies the line is in top part of rant.

....i get an error (2001) "you cancelled the previous operation" at the line Me.RecordSource = OpenArgs ....


It's obviously(??!) in the form load procedure of the form being opened.

Your right about the lack of spacing but as i can't get the damn thing to run i can't test the SQL

Chris
 
Ok, I was out late drinking last night and not in best form (no pun intended) today. Does the error you are receiving actually SAY "at the line Me.RecordSource = OpenArgs"?

When I read your statement I thought perhaps it was opening up the code and highlighting that line as being where the exception is thrown.

I had this same error code pop-up before and I'm trying to remember what code it was and what was causing it.
 
Last edited:
Hello

No the error is just occuring at that line of code. Any how i checked the select part of the query and that worked fine then i tried


StrSql = "SELECT TBL_PATIENT.*, TBL_SPELL.* " _
& "FROM TBL_PATIENT LEFT JOIN TBL_SPELL ON TBL_PATIENT.PMI = TBL_SPELL.PMI_FK " _
& "WHERE (((TBL_SPELL.CASE_TYPE_FK) like(" & "'" & COMBO5ID & "'" & ")) AND ((TBL_SPELL.OUTCOME_ID_FK) like(" & "'" & COMBO5ID & "'" & ")) AND ((IIf([OUTCOME_ID_FK]=0,round((DateDiff('d',[APPOINTMENT_DATE],Date())/7),2),'EPISODE CLOSED')) like(" & "'" & COMBO5ID & "'" & "))) ;"

and that seems to work

why? i haven't a scooby

probably you need to use like with "*" it can't work as a criteria by itself

Chris
 

Users who are viewing this thread

Back
Top Bottom