Code executes but control doesn't

H

Hugh self taught

Hi Guys & Gals,

I have a form that opens a confirmation form in Dialog mode. When the
confirmation form is closed the code from the originating form executes but
the control doesn't. I can close it on the "X" or the "close database" button
on the form but none of the other buttons or tabs execute.

Any suggestions as to what may cause my issue?
 
H

Hugh self taught

Hi Bonnie,

From my "Primary" form, I have a button which will execute a qry to update a
table. There is a button to call it & that button first opens a new form in
dialog mode which asks for confirmation & at the same time makes the
"Primary" form hidden. If the backup question's answer is "No" then I have a
msgbox to ask if you're sure. Then the "confirmation" form closes returning
execution to the "Primary" form & the "Primary" is made visible again.

I got it working by playing around with the .visible True / False being
placed in different places on the forms.

What I now really need help with is understanding how the .visible statement
should be placed. ie On the "Primary" form or the "Confirmation" form, True
on the one form False on the other? etc & it's behaviour. In other words a
bit more on the flow of control of the .visible property.

Maybe you can help me with that?

Cheers
 
H

Hugh self taught

Hi,

I have the Primary form.visible = False in the onload of the confirmation
form.

I make it visible again in the next line of code on the Primary form.

On the Confirmation form I make Me.visisble = false when the code is
finished executing.

Then after the code completes the update queries on the primary form I close
the confirmation form.

Hope that makes sense.

bhicks11 via AccessMonster.com said:
Where do you have it now and is it working? I would put the visible = true
in the pop up form onclose.

Bonnie
http://www.dataplus-svc.com
Hi Bonnie,

From my "Primary" form, I have a button which will execute a qry to update a
table. There is a button to call it & that button first opens a new form in
dialog mode which asks for confirmation & at the same time makes the
"Primary" form hidden. If the backup question's answer is "No" then I have a
msgbox to ask if you're sure. Then the "confirmation" form closes returning
execution to the "Primary" form & the "Primary" is made visible again.

I got it working by playing around with the .visible True / False being
placed in different places on the forms.

What I now really need help with is understanding how the .visible statement
should be placed. ie On the "Primary" form or the "Confirmation" form, True
on the one form False on the other? etc & it's behaviour. In other words a
bit more on the flow of control of the .visible property.

Maybe you can help me with that?

Cheers
What is supposed to execute? How are you opening the confirmation form? Are
you sure you are returning focus to the original form?
[quoted text clipped - 10 lines]
Any suggestions as to what may cause my issue?

--
Message posted via AccessMonster.com


.
 
H

Hugh self taught

It's working as I mentioned earlier. I just want to understand the transfer
of control between visible = true / false, dialog & modal forms.

bhicks11 via AccessMonster.com said:
Isn't that working well for you?

Bon
Hi,

I have the Primary form.visible = False in the onload of the confirmation
form.

I make it visible again in the next line of code on the Primary form.

On the Confirmation form I make Me.visisble = false when the code is
finished executing.

Then after the code completes the update queries on the primary form I close
the confirmation form.

Hope that makes sense.
Where do you have it now and is it working? I would put the visible = true
in the pop up form onclose.
[quoted text clipped - 28 lines]
Any suggestions as to what may cause my issue?

--
Message posted via AccessMonster.com


.
 
H

Hugh self taught

That sounds simple enough but is not quite the case since the one form is
opened in dialog mode.

What setting of .visible triggers the release of "freeze" on the dialog mode
form & at what point does control return to the calling form?

As I mentioned in my 1st post, code execution continued but control did not.
By trial & error I got it to work, but I need to understand the timing &
control transfer between the forms for .visible

bhicks11 via AccessMonster.com said:
Visible is a property of the form and you are simply change it to true or
false. ?

Bonnie
It's working as I mentioned earlier. I just want to understand the transfer
of control between visible = true / false, dialog & modal forms.
Isn't that working well for you?
[quoted text clipped - 20 lines]
Any suggestions as to what may cause my issue?

--
Message posted via AccessMonster.com


.
 
J

John W. Vinson

That sounds simple enough but is not quite the case since the one form is
opened in dialog mode.

What setting of .visible triggers the release of "freeze" on the dialog mode
form & at what point does control return to the calling form?

When you open a form in Dialog view, execution halts in the calling routine.
Execution will resume when either of two things happen: the dialog form is
closed, or its Visible property is set to False.
 
H

Hugh self taught

Hi John,

I see Bruce had a go at explaining for me which I appreciate but your brief
explanation was more the points I'm trying to get to understand. Maybe what's
confusing the issue for me was that at my first go with a dialog form I got
the calling form to continue code execution however the control was not
returned to the calling form.

By that I mean that buttons to execute other coded queries would not
function but I could close the form manually & the button in the calling
forms footer which closes the database did work. The calling form has tabs &
they wouldn't function either. So in essence I'm trying to understand the
timing & transfer of control using a dialog form & the effect of .visible &
which form should have those instructions. At the moment it's a bit of "as
clear as mud" as my dad used to say.

Thanks for helping
 
H

Hugh self taught

Thanks Bruce,

Briefly reading through I already see timing I was not aware of. I'll be
keeping this until I'm up to speed in that area.

Cheers

BruceM via AccessMonster.com said:
Regarding the Visible property, you can use code (in a comman button, for
instance) on a form to hide that form (which is how you would proceed with a
Dialog form), or you can use it from another form using the syntax I
described. If you hide the main form and open a dialog form, you need to
make the main form visible from the dialog form. In the examples below I
added message boxes to help show the timing. They are not necessary. In the
main form:

Me.Visible = False
DoCmd.OpenForm "frmDialog", , , , ,acDialog
MsgBox "Back in business"

The second line could be:
DoCmd.OpenForm "frmDialog",WindowMode:=acDialog

In the Dialog form:

DoCmd.Close acForm,Me.Name
Forms!frmMain.Visible = True
MsgBox "Dialog form closing"

or, if you just want to hide the form:

Me.Visible = False
Forms!frmMain.Visible = True

In the main form, the form is hidden with the first line of code, then the
dialog form is opened with the next line of code. Code execution halts, as
John succinctly observed. Note that you need to hide the form before opening
the dialog form. Code execution continues even though the form is hidden,
but if the first two lines of code are reversed the Visible line of code will
not execute until the dialog form is closed or hidden.

In the dialog form (or any form) you can use Me.Name to close the form, or
you can use the name of the form in quotes:
DoCmd.Close acForm,"frmDialog"

Again, the code execution continues after closing or hiding the dialog form,
so the next line of code (and the rest of the procedure) runs. If you have
the message box code, you will first see the message "Dialog form closing",
then "Back in business". The code in the dialog form is still running, so
whatever is in the code comes before the code in the main form. Once the
dialog form code is stopped, focus returns to the main form, and the message
appears. In practice the dialog form will be hidden (or close), the main
form will become visible, the dialog form code will continue (showing you the
message box), and the main form code will resume where it left off (showing
you another message box).

Again, the message boxes are for illustration only. They can be useful for
sorting out timing issues.

I expect it is clear that frmMain and frmDialog are generic form names that
would be replaced by the actual form names, but I'll mention it anyhow.



Hi John,

I see Bruce had a go at explaining for me which I appreciate but your brief
explanation was more the points I'm trying to get to understand. Maybe what's
confusing the issue for me was that at my first go with a dialog form I got
the calling form to continue code execution however the control was not
returned to the calling form.

By that I mean that buttons to execute other coded queries would not
function but I could close the form manually & the button in the calling
forms footer which closes the database did work. The calling form has tabs &
they wouldn't function either. So in essence I'm trying to understand the
timing & transfer of control using a dialog form & the effect of .visible &
which form should have those instructions. At the moment it's a bit of "as
clear as mud" as my dad used to say.

Thanks for helping
That sounds simple enough but is not quite the case since the one form is
opened in dialog mode.
[quoted text clipped - 5 lines]
Execution will resume when either of two things happen: the dialog form is
closed, or its Visible property is set to False.

--
Message posted via AccessMonster.com


.
 

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