Customize my own msgbox

G

Guest

I have a form that i customized to look just like a msgbox. It has a label
and yes/no command buttons. When I write code that calls this form to open,
how can I:

1) pause the code that called the customized msgbox so that it waits for a
response from the user.

and

2) Return a yes value (if the user clicked the "yes" command button) or a no
value (if the user clicked the "no" command button) to the paused code so I
can use that value in a conditional statement.

Dan
 
D

Douglas J. Steele

1) Open the form as Modal. When using the OpenForm method, you need to
specify the WindowMode as acDialog.

2) You have to have your msgbox form write back to the calling form. If
you're only calling the form from a single place, it's fairly simple to set
a hidden value on the form or a public variable. If you're expecting to call
it from multiple forms, you'll need to pass the calling form's name to the
msgbox form (in the OpenArg property), and then use that information to
determine where to write the value back to.
 
F

fredg

I have a form that i customized to look just like a msgbox. It has a label
and yes/no command buttons. When I write code that calls this form to open,
how can I:

1) pause the code that called the customized msgbox so that it waits for a
response from the user.

The follow should take care of both questions.
To open and read the returned value from the message form:

DoCmd.OpenForm "MessageForm", , , , , acDialog
If forms!MessageForm![ControlName] = 1 Then
Do the Yes stuff
Else
Do the No stuff
End If
DoCmd.Close acForm, "MessageForm"

and

2) Return a yes value (if the user clicked the "yes" command button) or a no
value (if the user clicked the "no" command button) to the paused code so I
can use that value in a conditional statement.
Add an unbound control to the form.
Code the Yes command button:
Me![ControlName] = 1
Me.Visible = False

Code the No command button:
Me![ControlName] = 2
Me.Visible = False
 

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