Form closes the other form while changing to DesignView

M

Mishanya

I have a form with control button wich opens other form. Somehow the latter
form "have learnt" to close the former while I change it to DesignView. Other
similar forms "behave themselves" - so, I guess, I accidentally changed
something in the rebellious form.
What property is responsible for such a misbehaviour?
 
J

Jeanette Cunningham

Hi Mishanya,
check for any code in the unload event of the form that might be doing this.

Jeanette Cunningham
 
M

Mishanya

Hi,Jeanette.
There is no code related to this form at all eccept for CLose and
GoToNewRecord buttons. First I saw such a pattern in Microsoft example DB -
opening form and then opening its subform independently from the main DB
window and changing its view to Design mode would close the former form. This
made sense to me.
But in my case the second form is not a subform, though it's bound to the
former by link criteria. To double-check myself I've created another button
opening third form again with link criteria and tried to change it to Design
mode after opening - no problem.
So, I guess, it has something to do with the form properties.
What do U say?
 
J

Jeanette Cunningham

What do you have for the code on the main form that opens the other form for
each button?


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
M

Mishanya

On Error GoTo Err_btnOpenMyForm_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "MyForm"

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

Exit_btnOpenMyForm_Click:
Exit Sub

Err_btnOpenMyForm_Click:
MsgBox Err.Description
Resume Exit_btnOpenMyForm_Click
 
J

Jeanette Cunningham

That code looks fine.
Just to recap:
You open the main form
Then you use the button on the main form to open the 2nd form.
When you change the 2nd form to design view, the main form closes.
Am I understanding correctly?

If yes, the answer could be to look at the record source for both forms and
see it they are both using the same table.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Mishanya said:
On Error GoTo Err_btnOpenMyForm_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "MyForm"

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

Exit_btnOpenMyForm_Click:
Exit Sub

Err_btnOpenMyForm_Click:
MsgBox Err.Description
Resume Exit_btnOpenMyForm_Click


Jeanette Cunningham said:
What do you have for the code on the main form that opens the other form
for
each button?


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
M

Mishanya

Hi Jeanette.
Your recap is correct.
The main form has cboSelectClientID based on tblClientDetails' field ClientID.
The foms I open with button controls have ClientName field based on
tblClientDetails and subforms with related data. All of them but one open and
go to the Design mode without closing the 1st (main) form. Which means,
sharing fields from the same table does not affect the ability to switch to
Design Mode (otherwise the programm would toss some warning.

Jeanette Cunningham said:
That code looks fine.
Just to recap:
You open the main form
Then you use the button on the main form to open the 2nd form.
When you change the 2nd form to design view, the main form closes.
Am I understanding correctly?

If yes, the answer could be to look at the record source for both forms and
see it they are both using the same table.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Mishanya said:
On Error GoTo Err_btnOpenMyForm_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "MyForm"

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

Exit_btnOpenMyForm_Click:
Exit Sub

Err_btnOpenMyForm_Click:
MsgBox Err.Description
Resume Exit_btnOpenMyForm_Click


Jeanette Cunningham said:
What do you have for the code on the main form that opens the other form
for
each button?


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Hi,Jeanette.
There is no code related to this form at all eccept for CLose and
GoToNewRecord buttons. First I saw such a pattern in Microsoft example
DB -
opening form and then opening its subform independently from the main
DB
window and changing its view to Design mode would close the former
form.
This
made sense to me.
But in my case the second form is not a subform, though it's bound to
the
former by link criteria. To double-check myself I've created another
button
opening third form again with link criteria and tried to change it to
Design
mode after opening - no problem.
So, I guess, it has something to do with the form properties.
What do U say?

:

Hi Mishanya,
check for any code in the unload event of the form that might be doing
this.

Jeanette Cunningham

I have a form with control button wich opens other form. Somehow the
latter
form "have learnt" to close the former while I change it to
DesignView.
Other
similar forms "behave themselves" - so, I guess, I accidentally
changed
something in the rebellious form.
What property is responsible for such a misbehaviour?
 
J

Jeanette Cunningham

I have run out of ideas for this problem.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Mishanya said:
Hi Jeanette.
Your recap is correct.
The main form has cboSelectClientID based on tblClientDetails' field
ClientID.
The foms I open with button controls have ClientName field based on
tblClientDetails and subforms with related data. All of them but one open
and
go to the Design mode without closing the 1st (main) form. Which means,
sharing fields from the same table does not affect the ability to switch
to
Design Mode (otherwise the programm would toss some warning.

Jeanette Cunningham said:
That code looks fine.
Just to recap:
You open the main form
Then you use the button on the main form to open the 2nd form.
When you change the 2nd form to design view, the main form closes.
Am I understanding correctly?

If yes, the answer could be to look at the record source for both forms
and
see it they are both using the same table.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Mishanya said:
On Error GoTo Err_btnOpenMyForm_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "MyForm"

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

Exit_btnOpenMyForm_Click:
Exit Sub

Err_btnOpenMyForm_Click:
MsgBox Err.Description
Resume Exit_btnOpenMyForm_Click


:

What do you have for the code on the main form that opens the other
form
for
each button?


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Hi,Jeanette.
There is no code related to this form at all eccept for CLose and
GoToNewRecord buttons. First I saw such a pattern in Microsoft
example
DB -
opening form and then opening its subform independently from the
main
DB
window and changing its view to Design mode would close the former
form.
This
made sense to me.
But in my case the second form is not a subform, though it's bound
to
the
former by link criteria. To double-check myself I've created another
button
opening third form again with link criteria and tried to change it
to
Design
mode after opening - no problem.
So, I guess, it has something to do with the form properties.
What do U say?

:

Hi Mishanya,
check for any code in the unload event of the form that might be
doing
this.

Jeanette Cunningham

I have a form with control button wich opens other form. Somehow
the
latter
form "have learnt" to close the former while I change it to
DesignView.
Other
similar forms "behave themselves" - so, I guess, I accidentally
changed
something in the rebellious form.
What property is responsible for such a misbehaviour?
 
M

Mishanya

Your mentioning of using the same tables led me to remove some objects from
the 2nd form - and there it was. There are 2 subforms on the 2nd form, one of
wich is invisible and serves only the purpose of pulling some aggregate from
some elaborate query. The pulled value is used then as a default value in one
of the another subform' controls. After I deleted the first subform, the 2nd
form stopped closing the the 1st form while switching to Design Mode.
Although, I put it back, cause the value it provides is more important then
being able to switch to Design mode without putting the 1st form off.
I still don't know what pattern of using tables and queries may lead to such
a behaviour, but at least I can tell now where the reason might be hidden in
general.
Thank You, Jeanette.


Jeanette Cunningham said:
That code looks fine.
Just to recap:
You open the main form
Then you use the button on the main form to open the 2nd form.
When you change the 2nd form to design view, the main form closes.
Am I understanding correctly?

If yes, the answer could be to look at the record source for both forms and
see it they are both using the same table.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Mishanya said:
On Error GoTo Err_btnOpenMyForm_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "MyForm"

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

Exit_btnOpenMyForm_Click:
Exit Sub

Err_btnOpenMyForm_Click:
MsgBox Err.Description
Resume Exit_btnOpenMyForm_Click


Jeanette Cunningham said:
What do you have for the code on the main form that opens the other form
for
each button?


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Hi,Jeanette.
There is no code related to this form at all eccept for CLose and
GoToNewRecord buttons. First I saw such a pattern in Microsoft example
DB -
opening form and then opening its subform independently from the main
DB
window and changing its view to Design mode would close the former
form.
This
made sense to me.
But in my case the second form is not a subform, though it's bound to
the
former by link criteria. To double-check myself I've created another
button
opening third form again with link criteria and tried to change it to
Design
mode after opening - no problem.
So, I guess, it has something to do with the form properties.
What do U say?

:

Hi Mishanya,
check for any code in the unload event of the form that might be doing
this.

Jeanette Cunningham

I have a form with control button wich opens other form. Somehow the
latter
form "have learnt" to close the former while I change it to
DesignView.
Other
similar forms "behave themselves" - so, I guess, I accidentally
changed
something in the rebellious form.
What property is responsible for such a misbehaviour?
 

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

Top