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

Error opening one form from another, within the form_open event

Status
Not open for further replies.

scoobywilliams

IS-IT--Management
Apr 24, 2001
5
GB
I have a curious problem where, using the DoCmd.OpenForm under a button from one form, the form I am trying to open automatically cancels itself. I have two lines of code in the form_open event, however if commented out the 'feature' still occurs. If I remove the event code altogether the problem goes away.

It's as if the cancel value is set to True immediately though there is no code inbetween the OpenForm and the new form opening. The error returned is 2051.

Any suggestions more than welcome

Chris
 
Are you trying to close the form that has the button to open the second form?

Docmd.OpenForm "Form2"
Docmd.Close

This will Close Form2 as soon as it opens.
If this is the case then you should try

Docmd.OpenForm "Form2"
Docmd.Close "Form1"
' Or move the close command on top of the open command.

Just a thought,
ljprodev@yahoo.com
Professional Development
MS Access Applications
 
Unfortunately yes.
The Button on form1 has the following

DoCmd.OpenForm "frmGetSubscriber"
DoCmd.Close A_FORM, "frmMaintenanceMenu"

The event code on form2 is (for what it's worth)

Me![ogLogonType] = 6
Me![txtSubscriberDesc].Visible = False

I have tried putting the close form on form2 just in case there was a quirk there.

Chris
 
Have you tried going to the database window and opening the form without the control button to see if it opens. This will at least tell you which form your problem resides? ljprodev@yahoo.com
Professional Development
MS Access Applications
 
Thanks four your help, but I have resolved it now. The problem occurred whilst converting from 97 to 2000 and it would seem I had a compile error in some subsequent code. This was causing the form to bomb out. Always the simple things!

Thanks again

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top