RE: Why does DoCmd.OpenForm cause bouncing



I'm trying what you suggested though at the moment it's adding to my
confusion, not least because I've noticed that the second (spurious) Open
event for Form_B actually creates an identical instance of Form_B, which is
intriguing in itself but not what I want to see.

I'll persevere but in the meantime if you can think of anything else I'd
appreciate it.

Thanks for your help.
--
Ted Keating


"dch3" wrote:

I'm willing to bet that Focus is being returned to the First Form. Which
control on which form has the focus after the form opens? Try playing around
with putting code in the GotFocus and LostFocus events for the Form.

"Edward" wrote:

I have two forms, say A and B. A is set to open at start and it has a button
to allow the user to open form B (without closing Form A). In my live
solution I have problems I've been unable to fathom but the code is too long
to make debugging easy.

So, I created a very simple database that does nothing more than "Msgbox"
the path taken through the Open>Load>Activate>Current events.

That shows Form_A results in this sequence of events:
Open>Load>Activate>Current, which is exactly as it should be according to the
Access documentation.
However, when I click the "Open Form B" button the events occur in this
sequence:
Form_B_Open >Form_B_Load >Form_A_Deactivate >Form_B_Activate >Form_B_Current
Form_B_Open >Form_B Load >Form_B Deactivate >Form_B_Activate >Form_B_Current>

It's OK up to the ">Form_B_Current" but I can't understand why it goes on to
repeat the >Form_B Load >Form_B Deactivate >Form_B_Activate >Form_B_Current>
events.

The following code will fathfully reproduce it, please try it and put me out
of my misery, Thanks, Ted:

Form_A event code:
Option Explicit

Private Sub Admin_Click() ' This is a button on Form_A pointing to this
click event
DoCmd.OpenForm Form_Form_B.Name
End Sub

Private Sub Form_Activate()
MsgBox Me.Name & " Activate"
End Sub

Private Sub Form_Current()
MsgBox Me.Name & " Current"
End Sub

Private Sub Form_Deactivate()
MsgBox Me.Name & " De-Activate"
End Sub

Private Sub Form_Load()
MsgBox Me.Name & " Load"
End Sub

Private Sub Form_Open(Cancel As Integer)
MsgBox Me.Name & " Open"
End Sub

Form_B event code:
Option Compare Database

Private Sub Form_Activate()
MsgBox Me.Name & " Activate"
End Sub

Private Sub Form_Current()
MsgBox Me.Name & " Current"
End Sub

Private Sub Form_Deactivate()
MsgBox Me.Name & " DeActivate"
End Sub

Private Sub Form_Load()
MsgBox Me.Name & " Load"
End Sub

Private Sub Form_Open(Cancel As Integer)
MsgBox Me.Name & " Open"
End Sub

--
Ted Keating
.