Getting a value from a dialog Form

  • Thread starter Thread starter Morris
  • Start date Start date
M

Morris

Hi,

I seem to be stuck and although I'm still looking for a solution I
decided I'll give it a try and ask you for help as well.

I've got this function: (I've numbered the lines here, they don't
exist in the real project)
Public Function fncNewGrossCost() As Long
1:
2: DoCmd.OpenForm "frmNewGCost", acNormal, , , , acDialog
3: fncNewGrossCost = Nz(Forms("frmNewGCost").txtNewGCostAccepted, 0)
4: DoCmd.Close acForm, "frmNewGCost"
End Function

It's supposed to open a form with one textbox (txtNewGCostAccepted)
and one button (cmdConfirm)
The user is supposed to type the new cost, press confirm and what I
want then to happen is for the function fncNewGrossCost to be able to
check what the value was - and return it to the invoking function.

And somehow I can't make it work. I decided I'd need to use the
acDialog parameter to stop code execution. I've read somewhere on this
group that the onClick event of cmdConfirm button should say:

Me.Visible = False

which should be enough to make the code execution continue from line 3
of the above mentioned function.
Is this the correct approach?
 
Hey Albert,
Thanks for the explanation about modal and dialog forms. How do these
differ from forms that have the popup attribute set?

Thanks,
Chris M.

------------

Great question!! in fact, I likely should add a popup section to that
article. Popup is another one of those often miss used features. If you make
one form popup, it will REMAIN on top of every other form. Of course, this
means that if you make the form popup when you don't need to, next thing you
know you starting to make every other form popup because nothing opens on
top of that form! Doing this by accident can really make a mess.

The *other* important feature of a popup form is that it does NOT NEED to
have the focus to be displayed on top. So, for your own wizard type forms,
or even a "display" form that shows some information about a customer
*while* you edit a different form is a good use of popup. So, popup not only
stays on top of EVERY thing else, it does NOT need to have the focus while
you in another form. This type of form is almost like clippy the lost paper
clip guy that was removed from office!

So, you can pop up (pun intended) a information form with some help
instructions, or to just display some additional information *while* the
user continues to enter data into a *different* form. So, popup forms can
stay on top to display things, but NOT have the focus.

Needless to say, if you accidentally make a form popup, you often see the
person then starting to make just about all forms popup, and you rapidly get
a situation like a dog chasing its tail.

For the most part, a form rarely needs to be popup, and control of what form
is on top is usually done via the model setting (most of my forms are
model).

As a general rule, I don't recommend using a dialog forms either unless all
other options have been exhausted. The reason being is that custom menus
etc. don't work, and your code does halt. While often this makes coding
easier, from a user interface point of view, it tends to be a less user
friendly design. So, for some "prompt" type forms, dialog is ok....but, for
data entry forms you want to avoid dialog. Furthermore, if you want multiple
copies of the form open, then the form cannot be dialog anyway. So, you
can't have multiple instances of the form open if the form is to be dialog.

More and more, my designs allow multiple instances of a form to be opened,
and thus I am using dialog forms less and less...
 
Thanks for the explanation about modal and dialog forms.  How do these
differ from forms that have the popup attribute set?

Thanks,
Chris M.

------------

Great question!! in fact, I likely should add a popup section to that
article. Popup is another one of those often miss used features. If you make
one form popup, it will REMAIN on top of every other form. Of course, this
means that if you make the form popup when you don't need to, next thing you
know you starting to make every other form popup because nothing opens on
top of that form! Doing this by accident can really make a mess.

The *other* important feature of a popup form is that it does NOT NEED to
have the focus to be displayed on top. So, for your own wizard type forms,
or even a "display" form that shows some information about a customer
*while* you edit a different form is a good use of popup. So, popup not only
stays on top of EVERY thing else, it does NOT need to have the focus while
you in another form. This type of form is almost like clippy the lost paper
clip guy that was removed from office!

So, you can pop up (pun intended) a information form with some help
instructions, or to just display some additional information *while* the
user continues to enter data into a *different* form. So, popup forms can
stay on top to display things, but NOT have the focus.

Needless to say, if you accidentally make a form popup, you often see the
person then starting to make just about all forms popup, and you rapidly get
a situation like a dog chasing its tail.

For the most part, a form rarely needs to be popup, and control of what form
is on top is usually done via the model setting (most of my forms are
model).

As a general rule, I don't recommend using a dialog forms either unless all
other options have been exhausted. The reason  being is that custom menus
etc. don't work, and your code does halt. While often this makes coding
easier, from a user interface point of view, it tends to be a less user
friendly design. So, for some "prompt" type forms, dialog is ok....but, for
data entry forms you want to avoid dialog. Furthermore, if you want multiple
copies of the form open, then the form cannot be dialog anyway. So, you
can't have multiple instances of the form open if the form is to be dialog..

More and more, my designs allow multiple instances of a form to be opened,
and thus I am using dialog forms less and less...

Thanks for a great explanation. Opens my eyes to all the mistakes
I've made in the last 10 years.... B-)

One final question.
More and more, my designs allow multiple instances of a form to be opened,
and thus I am using dialog forms less and less...

Is this possible in Access 2002?

Thanks again,
Chris M.
 
Back
Top