does a window or dialog have a return value when closed

A

Alan

I have a dialog that does a search and needs to return the search results to
the calling function. Especially if the seach is cancelled or produces no
result.

When a result is produced, I can handle that by updating a control on the
calling form, but unless I have hidden controls on the calling form, I can't
return a cancelled or no find result.

A return value would be handy if it exists, or can be created

Thanks
 
J

John W. Vinson

I have a dialog that does a search and needs to return the search results to
the calling function. Especially if the seach is cancelled or produces no
result.

When a result is produced, I can handle that by updating a control on the
calling form, but unless I have hidden controls on the calling form, I can't
return a cancelled or no find result.

A return value would be handy if it exists, or can be created

A Form doesn't return a value... but you can get it with a trick.

Opening a form in Dialog mode pauses the calling code until the form is
closed... *or becomes invisible*. Put a button on the dialog form (labeled
Close, or Done, or whatever) that the user can click to terminate that form.
Its click event should just do

Me.Visible = False

The calling code will then resume, and can refer to

=Forms!dialogformname!controlname

(or multiple controls, if appropriate) to retrieve the value(s). It should
then explicitly close the (now invisible) form:

DoCmd.Close acForm, "dialogformname
"
 

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