popup form like msgbox

J

JString

I need some option to call a procedure similar to msgbox, get info from the
user, and resume. The info I need from the users is more complex than what's
offered through the msgbox function. How can I go about writing a procedure
that would mimick msgbox but use my own custom form?

Thanks in advance.
 
G

Graham R Seach

Well, there are two options.

For simple scenarios you can use the InputBox() function, which allows you
to collect a single value from the user:
varMyInput = InputBox("A user prompt","A title for the InputBox", "A
default value")

For more complex scenarios, you will have to create your own custom form.
How you call that form into existence depends on your preference, and there
are two options:

Firstly, you can call the form using the standard DoCmd.OpenForm method and
setting the WindowMode argument to acDialog.
DoCmd.OpenForm "frmMyDialog", , , , , acDialog

In your custom dialog, provide a command button to "close" the form. What
what it should actually do is set the form's Visible property = False,
rather than close it.
Private Sub cmdClose_Click()
Me.Visible = False
End Sub

Then immediately following the OpenForm code, you write code to extract the
data you want from the (now hidden) dialog, and close the form.
Me!txtSomeTextbox = Forms!frmMyDialog!txtSomeOtherTextBox
DoCmd.Close acForm, "frmMyDialog"

Secondly, you can instantiate the form using object-oriented techniques. See
the following website for information about how to do that:
http://www.pacificdb.com.au/MVP/Code/MyDialog.htm

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
J

JString

Thanks for the help.

The thing that isn't clear to me at the moment is if I can call this form
into existence using a single, easy to use function just like msgbox().
Currently I have a module that opens reports using a function called
OpenReport(). What I need is to have this function call the dialog before
opening a report, wait until the form is closed and resume with the rest of
its code and finally open the report. Is that possible?
 
J

JString

does the dialog window mode take care of that?

JString said:
Thanks for the help.

The thing that isn't clear to me at the moment is if I can call this form
into existence using a single, easy to use function just like msgbox().
Currently I have a module that opens reports using a function called
OpenReport(). What I need is to have this function call the dialog before
opening a report, wait until the form is closed and resume with the rest of
its code and finally open the report. Is that possible?
 
J

JString

Nevermind, I tried what you said and it does everything I need it to. Thanks
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