Return value from dialog box

fearoffours

Registered User.
Local time
Today, 12:14
Joined
Apr 10, 2008
Messages
82
I know that you can use

myvar = MsgBox("Some prompt", vbYesNo)

to get an input from a user to dictate subsequent actions.
However, if you would like input but need more freedom than yes/No Ok/Cancel Abort/Retry/Ignore, then how do you go about doing this?

I thought that you would simply use a custom form, then I realised that this would entail using the form to set a public variable.
Is there a neater way to do this?
 
Fear,

There are a couple of options.

1) Use an InputBox (See Help).

2) Use a custom form. You don't have to set a Global Variable, as long as
the form is open, you can reference like:

Forms!YourCustomForm!SomeFieldName

hth,
Wayne
 
Thanks Wayne.

My preferred plan was to have a form with 3 buttons. Each button would close the form but return a value to the function that called this form.
I think I'll go with the global varial after all.

Using InputBox would mean specifying the user typed '1 for option 1, 2 for option 2, or 3 for option 3', which is a bit clunky.
 
Fear,

The custom form is a good choice, but I'm not too sure about the global
variable.

The variable won't be available for queries unless you return it with a
Public function.

Your custom form could communicate back to the main form:

Forms!YourMainForm!TheValue = Me.CustomFormOption

Then, anything can reference the value.

Wayne
 

Users who are viewing this thread

Back
Top Bottom