Runtime error 2001

  • Thread starter Thread starter m44pablo
  • Start date Start date
M

m44pablo

Have 2 command buttons that open 1 form.
First button opens fine with the specied recordsource but
the other one comes up with
"Runtime error 2001
You canceled the previous operation."


code as follows:
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmOrgSurveyModule"

stLinkCriteria = "[Org_seqno]=" & "'" & Me![Org_seqno]
& "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

If IsFormLoaded("frmOrganization") = True Then
Forms!frmOrgsurveymodule.txtorg_seqno = Me.Org_seqno
Forms!frmOrgsurveymodule.Label1.Caption = "PEP
CONSULTANT IMPLEMENTATION SURVEY"
Forms!frmOrgsurveymodule.lblSurveyMonth.Visible =
True
Forms!frmOrgsurveymodule.frmSurveyMonth.Enabled =
True
Forms!frmOrgsurveymodule.frmSurveyMonth.Locked =
False
Forms!frmOrgsurveymodule.frmSurveyMonth.Visible =
True
Forms!frmOrgsurveymodule.RecordSource = "select *
from tblorgsurveymodule where survey_mo in (3,6,9,12)"




End If

if I try to debug it - just highlight the recordsource.
Can't figure this out!!!
I need to change the recordsource if the other button is
pressed.
Help.
Thanks.
 
Error 2001 generally means that the SQL string is incorrect, or that there
is a record in the form that cannot be saved at present, so the RecordSource
can't be changed.

If you open tblOrgSurveyModule in design view, what is the Data Type of the
Survey_Mo field?

If Text (not Number), you need quotes around the arguments, i.e.:
Forms!frmOrgsurveymodule.RecordSource = _
"select * from tblorgsurveymodule where survey_mo in ('3','6','9','12')"

If that still does not work, create a new query, and paste in the contents
of your string into SQL View (View menu when in query design) to see what's
wrong.

The other thing is to test the Dirty property of the form before assigning
the RecordSource.
 
Thank you for your advise.
It now works.
-----Original Message-----
Error 2001 generally means that the SQL string is incorrect, or that there
is a record in the form that cannot be saved at present, so the RecordSource
can't be changed.

If you open tblOrgSurveyModule in design view, what is the Data Type of the
Survey_Mo field?

If Text (not Number), you need quotes around the arguments, i.e.:
Forms!frmOrgsurveymodule.RecordSource = _
"select * from tblorgsurveymodule where survey_mo in ('3','6','9','12')"

If that still does not work, create a new query, and paste in the contents
of your string into SQL View (View menu when in query design) to see what's
wrong.

The other thing is to test the Dirty property of the form before assigning
the RecordSource.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Have 2 command buttons that open 1 form.
First button opens fine with the specied recordsource but
the other one comes up with
"Runtime error 2001
You canceled the previous operation."


code as follows:
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmOrgSurveyModule"

stLinkCriteria = "[Org_seqno]=" & "'" & Me! [Org_seqno]
& "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

If IsFormLoaded("frmOrganization") = True Then
Forms!frmOrgsurveymodule.txtorg_seqno = Me.Org_seqno
Forms!frmOrgsurveymodule.Label1.Caption = "PEP
CONSULTANT IMPLEMENTATION SURVEY"
Forms!frmOrgsurveymodule.lblSurveyMonth.Visible =
True
Forms!frmOrgsurveymodule.frmSurveyMonth.Enabled =
True
Forms!frmOrgsurveymodule.frmSurveyMonth.Locked =
False
Forms!frmOrgsurveymodule.frmSurveyMonth.Visible =
True
Forms!frmOrgsurveymodule.RecordSource = "select *
from tblorgsurveymodule where survey_mo in (3,6,9,12)"




End If

if I try to debug it - just highlight the recordsource.
Can't figure this out!!!
I need to change the recordsource if the other button is
pressed.
Help.
Thanks.


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Runtime error 2001 2
runtime error 2001 1
Runtime error 2501 3
debug error 1
Runtime error 2501 8
Help, Runtime error 2001, You Canceled the Previous Operation 3

Back
Top