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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wierd error 1

Status
Not open for further replies.

snipesnab

IS-IT--Management
Oct 24, 2002
171
GB
I am trying to open a form by pushing a command button on another form but am getting the error message: "You cancelled the previous operation". I know the code is right but i can't see why it is giving me this error. Can anyone help?

the code i have used is:

docmd.openform "frm instructions" , acnormal
 
Show us the rest of the code... =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.
 
Thats the only code assosiated with that command button...
 
Hmm. Any code in the open or load event of the form? =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.
 
This is the code that runs when the form opens:

Private Sub Form_Open(Cancel As Integer)
On Error GoTo err_Form_Open

DoCmd.SetWarnings False
DoCmd.OpenQuery "qry del blank fields", acViewNormal
DoCmd.SetWarnings True

Me.Refresh


DoCmd.GoToRecord , , acNewRec


'Me.txtdatelogged.Value = Now()
Me.TxtPhonenumber.Visible = False
Me.lblphone.Visible = False



exit_Form_Open:
Exit Sub

err_Form_Open:
MsgBox Err.Description
Resume exit_Form_Open

End Sub
 
Step through the code. Where do you get the error?

=============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.
 
I get the error in the when I try to open the form by pushing a button with the code that only opens a form:

docmd.openform "formname",acnormal

thats the only code behind the button.
 
Hi!

You get this error message when you stop the form from opening either programmatically or manually. This often occurrs when a programmer checks to be sure that there are records in the recordset of the form and then closes the form if there isn't. Assuming the second form is opening the way you want it to, including automatically closing when it should, then trap for the error in the code behind your button like this:

OnError Go To Err_Handler

docmd.openform "formname",acnormal

Err_Handler
If Err.Number = 2701 (I think this is the right number, but just let the error happen and get the number there) Then
Resume Next
Else
Call MsgBox(Err.Number & ": " & Err.Description)
End If

This will exit the Sub when the error is the one you are getting and still allow other errors to be displayed to the user.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Tried the code you supplied but still brings up the error. I checked the error no : 2001 and put that in the first part of the error handler but still no luck.. is there another way I can get the form to open when someone needs to see it. The form contains instructions and help text.
 
Hi!

If it isn't sensitive in nature, you can zip and send me the db to look at. It sounds like something odd is going on here and we may be picking on the wrong operation as being cancelled.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top