make execution wait for button push - like msgbox?

G

Guest

Is there some way to create a form that will suspend execution of the code
that calls it, until the user presses an OK button - so it works the way
msgbox works?

I'd use msgbox, but I need to include a checkbox on the form so the user can
choose to not see this message again.
 
B

Brendan Reynolds

DoCmd.OpenForm "FormName", , , , , acDialog

The 'acDialog' argument causes the calling code to pause until the form is
closed or its Visible property is changed to False.
 
D

David C. Holley

Yes, just insert the msgbox function in an if...then statement where you
want the code to stop. *However*, what are you trying to accomplish -
why do you want the code to halt for user input?
 
G

Guest

Thanks a lot. That should do it.



Brendan Reynolds said:
DoCmd.OpenForm "FormName", , , , , acDialog

The 'acDialog' argument causes the calling code to pause until the form is
closed or its Visible property is changed to False.
 
G

Guest

Seems to me that the msgbox stops whatever code it's inserted into, but maybe
I'm not understanding. What I'm trying to accomplish is a message box that
has a checkbox that the user can click to set a variable so that message box
is not shown again. I want it to stop the code where it's inserted, so the
user can be notified of whatever, and then continue - but then once the user
has memorized the message he can click the checkbox so he won't have to see
the message over and over again.

It looks like Mr. Renolds has a simple solution.

Thanks for your help.
 
G

Guest

Hmmm, it doesn't seem to work for me. The form opens OK, but the code just
continues on (in this case opening up an Excel application) and the user
never sees the message form until (Excel is closed and) the calling code
comes to a resting point. Any ideas what I might be doing wrong?

DoCmd.OpenForm "Notification", , , , , acDialog

Thanks again.
 
D

David C. Holley

So then what is the specific text of the message that your presenting?

How/where are you storing the value so that the msgBox is not displayed
more than once?

In regards to the other post (the code continues to run) please post the
code?
 
B

Brendan Reynolds

As David says elsewhere in this thread, we'd need to see the code to be able
to help.
 
G

Guest

Actually, I've got a lot of different messages to be displayed by this
system. The messages, their ID number, and the boolean indicating whether
the user still wants to see this message are all stored in a 3-field table,
but all that really confuses the issue at hand.

Here's some simplified code. When I execute this, the dialog box opens
correctly, but the code continues to execute, but interestingly it opens the
next form behind the dialog box. In my actual application I open an Excel
spreadsheet following a dialog box, and Excel opens over the top of the
dialog, rather than underneath it.

Thanks again for your help.


Private Sub Command0_Click()

' Call the optional notification, hoping that code will stop and wait for user
Call ShowNotice

' Continue on with whatever process (open another form)
DoCmd.OpenForm "AnyOtherForm"
DoCmd.Maximize

End Sub



Private Sub ShowNotice()

' Open notification form in hidden mode, to check and see if user still
wants to see this notice
DoCmd.OpenForm "z Notification", acNormal, "", "", , acHidden

If Forms![z Notification]![ShowIt] = -1 Then ' Has user elected not to
see this notice again?
DoCmd.OpenForm "z Notification", , , , , acDialog ' Show the notice,
open visible as dialog
Else
DoCmd.Close acForm, "z Notification" ' User doesn't want to see this
again, close the hidden form
End If
End Sub
 
J

John Spencer

I think the Problem with the code is in these lines

DoCmd.OpenForm "z Notification", acNormal, "", "", , acHidden

If Forms![z Notification]![ShowIt] = -1 Then ' Has user elected not to
see this notice again?
DoCmd.OpenForm "z Notification", , , , , acDialog ' Show the notice,
open visible as dialog

Since the form is already open, the second open statement doesn't open it in
Dialog mode. If you can't get the value of ShowIt some other way (and you
must be storing it someplace) then you probably will have to close the form
and then open it again in dialog mode.

DoCmd.Close acForm, "z Notification"
DoCmd.OpenForm "z Notification",WindowMode:=acDialog




waynemb said:
Actually, I've got a lot of different messages to be displayed by this
system. The messages, their ID number, and the boolean indicating whether
the user still wants to see this message are all stored in a 3-field
table,
but all that really confuses the issue at hand.

Here's some simplified code. When I execute this, the dialog box opens
correctly, but the code continues to execute, but interestingly it opens
the
next form behind the dialog box. In my actual application I open an Excel
spreadsheet following a dialog box, and Excel opens over the top of the
dialog, rather than underneath it.

Thanks again for your help.


Private Sub Command0_Click()

' Call the optional notification, hoping that code will stop and wait for
user
Call ShowNotice

' Continue on with whatever process (open another form)
DoCmd.OpenForm "AnyOtherForm"
DoCmd.Maximize

End Sub



Private Sub ShowNotice()

' Open notification form in hidden mode, to check and see if user still
wants to see this notice
DoCmd.OpenForm "z Notification", acNormal, "", "", , acHidden

If Forms![z Notification]![ShowIt] = -1 Then ' Has user elected not to
see this notice again?
DoCmd.OpenForm "z Notification", , , , , acDialog ' Show the notice,
open visible as dialog
Else
DoCmd.Close acForm, "z Notification" ' User doesn't want to see this
again, close the hidden form
End If
End Sub



David C. Holley said:
So then what is the specific text of the message that your presenting?

How/where are you storing the value so that the msgBox is not displayed
more than once?

In regards to the other post (the code continues to run) please post the
code?
 
G

Guest

Hmm, I'll have to try that. I wondered about it, but it does seem that the
second call supercedes the first. On the second call the form is opened
visibly, and it seems to be in dialog mode, as it locks up the application
until the OK button is pushed to close it.

Thanks

John Spencer said:
I think the Problem with the code is in these lines

DoCmd.OpenForm "z Notification", acNormal, "", "", , acHidden

If Forms![z Notification]![ShowIt] = -1 Then ' Has user elected not to
see this notice again?
DoCmd.OpenForm "z Notification", , , , , acDialog ' Show the notice,
open visible as dialog

Since the form is already open, the second open statement doesn't open it in
Dialog mode. If you can't get the value of ShowIt some other way (and you
must be storing it someplace) then you probably will have to close the form
and then open it again in dialog mode.

DoCmd.Close acForm, "z Notification"
DoCmd.OpenForm "z Notification",WindowMode:=acDialog




waynemb said:
Actually, I've got a lot of different messages to be displayed by this
system. The messages, their ID number, and the boolean indicating whether
the user still wants to see this message are all stored in a 3-field
table,
but all that really confuses the issue at hand.

Here's some simplified code. When I execute this, the dialog box opens
correctly, but the code continues to execute, but interestingly it opens
the
next form behind the dialog box. In my actual application I open an Excel
spreadsheet following a dialog box, and Excel opens over the top of the
dialog, rather than underneath it.

Thanks again for your help.


Private Sub Command0_Click()

' Call the optional notification, hoping that code will stop and wait for
user
Call ShowNotice

' Continue on with whatever process (open another form)
DoCmd.OpenForm "AnyOtherForm"
DoCmd.Maximize

End Sub



Private Sub ShowNotice()

' Open notification form in hidden mode, to check and see if user still
wants to see this notice
DoCmd.OpenForm "z Notification", acNormal, "", "", , acHidden

If Forms![z Notification]![ShowIt] = -1 Then ' Has user elected not to
see this notice again?
DoCmd.OpenForm "z Notification", , , , , acDialog ' Show the notice,
open visible as dialog
Else
DoCmd.Close acForm, "z Notification" ' User doesn't want to see this
again, close the hidden form
End If
End Sub



David C. Holley said:
So then what is the specific text of the message that your presenting?

How/where are you storing the value so that the msgBox is not displayed
more than once?

In regards to the other post (the code continues to run) please post the
code?

waynemb wrote:
Seems to me that the msgbox stops whatever code it's inserted into, but
maybe
I'm not understanding. What I'm trying to accomplish is a message box
that
has a checkbox that the user can click to set a variable so that
message box
is not shown again. I want it to stop the code where it's inserted, so
the
user can be notified of whatever, and then continue - but then once the
user
has memorized the message he can click the checkbox so he won't have to
see
the message over and over again.

It looks like Mr. Renolds has a simple solution.

Thanks for your help.

:


Yes, just insert the msgbox function in an if...then statement where
you
want the code to stop. *However*, what are you trying to accomplish -
why do you want the code to halt for user input?

waynemb wrote:

Is there some way to create a form that will suspend execution of the
code
that calls it, until the user presses an OK button - so it works the
way
msgbox works?

I'd use msgbox, but I need to include a checkbox on the form so the
user can
choose to not see this message again.
 
G

Guest

You are correct. The "dialog" form has some dialog features when it's opened
hidden and then opened again visible, but it won't stop further code
execution unless it's closed before it's opened in dialog mode.

Thanks again.




John Spencer said:
I think the Problem with the code is in these lines

DoCmd.OpenForm "z Notification", acNormal, "", "", , acHidden

If Forms![z Notification]![ShowIt] = -1 Then ' Has user elected not to
see this notice again?
DoCmd.OpenForm "z Notification", , , , , acDialog ' Show the notice,
open visible as dialog

Since the form is already open, the second open statement doesn't open it in
Dialog mode. If you can't get the value of ShowIt some other way (and you
must be storing it someplace) then you probably will have to close the form
and then open it again in dialog mode.

DoCmd.Close acForm, "z Notification"
DoCmd.OpenForm "z Notification",WindowMode:=acDialog




waynemb said:
Actually, I've got a lot of different messages to be displayed by this
system. The messages, their ID number, and the boolean indicating whether
the user still wants to see this message are all stored in a 3-field
table,
but all that really confuses the issue at hand.

Here's some simplified code. When I execute this, the dialog box opens
correctly, but the code continues to execute, but interestingly it opens
the
next form behind the dialog box. In my actual application I open an Excel
spreadsheet following a dialog box, and Excel opens over the top of the
dialog, rather than underneath it.

Thanks again for your help.


Private Sub Command0_Click()

' Call the optional notification, hoping that code will stop and wait for
user
Call ShowNotice

' Continue on with whatever process (open another form)
DoCmd.OpenForm "AnyOtherForm"
DoCmd.Maximize

End Sub



Private Sub ShowNotice()

' Open notification form in hidden mode, to check and see if user still
wants to see this notice
DoCmd.OpenForm "z Notification", acNormal, "", "", , acHidden

If Forms![z Notification]![ShowIt] = -1 Then ' Has user elected not to
see this notice again?
DoCmd.OpenForm "z Notification", , , , , acDialog ' Show the notice,
open visible as dialog
Else
DoCmd.Close acForm, "z Notification" ' User doesn't want to see this
again, close the hidden form
End If
End Sub



David C. Holley said:
So then what is the specific text of the message that your presenting?

How/where are you storing the value so that the msgBox is not displayed
more than once?

In regards to the other post (the code continues to run) please post the
code?

waynemb wrote:
Seems to me that the msgbox stops whatever code it's inserted into, but
maybe
I'm not understanding. What I'm trying to accomplish is a message box
that
has a checkbox that the user can click to set a variable so that
message box
is not shown again. I want it to stop the code where it's inserted, so
the
user can be notified of whatever, and then continue - but then once the
user
has memorized the message he can click the checkbox so he won't have to
see
the message over and over again.

It looks like Mr. Renolds has a simple solution.

Thanks for your help.

:


Yes, just insert the msgbox function in an if...then statement where
you
want the code to stop. *However*, what are you trying to accomplish -
why do you want the code to halt for user input?

waynemb wrote:

Is there some way to create a form that will suspend execution of the
code
that calls it, until the user presses an OK button - so it works the
way
msgbox works?

I'd use msgbox, but I need to include a checkbox on the form so the
user can
choose to not see this message again.
 

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