Access MODAL form does not seem to act "MODALLY"

M

Michael

Sorry this is a bit long but I hope it is clear...

I have a parameter field PARAM on a parameter form into which I want to
enter a string validated as comprising three parts made up from different
fields in the database.

In "native" form on the parameter form it works well as follows:
1 - Double click on PARAM field and that makes a combo box visible and hides
the PARAM field.
2 - Select from combo and on tab (lost focus) make next combo visible....
etc.
3 - on completion of last combo and tab (lost focus) build the PARAM value
from the Me.cbo...values and makes all cbos visible=false and PARAM
visible=true.

It works exactly as I want it to !!

However, I want to use the same functionality in several places in the
database.

The tidiest way seemed to be to create a Function (I'm not into class
modules)

OnDoubleClick of PARAM
PARAM=PickImage

Function PickImage opens a small POPUP, MODAL form called frmPickImage with
three cbo boxes similar to those in the "native" version and uses the same
basic processing as the "native" form. This works fine within frmPickImage
itself but the problem is that the Function does not work because Access
does not seem to treat the small form as truly modal and only return program
control when the user has completed input - it seems to by asynchronous. The
code for the funciiton below illustrates what happens.

Public Function PickImage()

DoCmd.OpenForm ("frmPickImage") ' This opens the form fine
and triggers the OnOpen event of the form but when open processing completes
'
program flow IMMEDIATELY returns to the next line rather than waiting for
the user to complete data
'
entry and build the (Public) mcCurrentImagePath value from the three cbo
values.
PickImage = mcCurrentImagePath ' Therefore, since the
value has not been set the function returns null
'
The frustration is that the frmPickImage works fine and the
mcCurrentImagePath is built fine but sort-of arrives
' too late and the function has ended !!!!!!
End Function

It is driving me mad - any help please?

Michael.
 
T

Tom van Stiphout

On Sun, 4 Apr 2010 18:47:09 +0100, "Michael" <[email protected]>
wrote:

What you need is:
DoCmd.OpenForm "frmPickImage", WindowMode:=acDialog

-Tom.
Microsoft Access MVP
 
D

David W. Fenton

What you need is:
DoCmd.OpenForm "frmPickImage", WindowMode:=acDialog

I have never quite understood the meaning of the Modal property in a
form. To my way of thinking it ought to be equivalent to specifying
acDialog with DoCmd.OpenForm, but it clearly is not.

What is it for?
 
T

Tom van Stiphout

On 6 Apr 2010 00:21:26 GMT, "David W. Fenton"

I have wondered about that myself. The property seems to create some
modal behavior without the blocking DoCmd.OpenForm call.

-Tom.
Microsoft Access MVP
 
R

Rick Brandt

David said:
I have never quite understood the meaning of the Modal property in a
form. To my way of thinking it ought to be equivalent to specifying
acDialog with DoCmd.OpenForm, but it clearly is not.

What is it for?

It's for forcing the user to deal with the form and close it before they can
do anything else in the app. Can you envision no circumstance where that is
desirable without the code-pausing behavior of acDialog?
 
D

David W. Fenton

I have wondered about that myself. The property seems to create
some modal behavior without the blocking DoCmd.OpenForm call.

So how is that "modal"? It contradicts my understanding of the
fundamental definition of the term.
 
D

David W. Fenton

It's for forcing the user to deal with the form and close it
before they can do anything else in the app. Can you envision no
circumstance where that is desirable without the code-pausing
behavior of acDialog?

None at all, in fact.
 

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