How to pass a value to a popup.... again

  • Thread starter Thread starter Neil
  • Start date Start date
N

Neil

I opened a popup form and then opened a dialog box from this popup. I
needed to enter information into a text field on the dialog box and
then pass it back to another textfield in the popup. I have not been
able to do this.

I tried:

Setting Control Rowsource Property on the Popup like this:

=Forms![frmDialogBoxName]!txtFieldDialog

That doesn't work. The value never passes from the DialogBox to the
Popup.


Next I tried:
Creating a global variable and trying to set the control rowsource
equal to that and that didn't work.

Now I am trying to pass the handle like this:

DoCmd.OpenForm "frmDialogBox", , , , , acDialog, Me.hwnd

The only problem is how can I use this (the OpensArgs property) to
reference the popup and pass a value back to it. I am a newbie to
Access VBA and I know I am not understanding something here but I just
don't get it.

Why won't a txtBox value pass from a form to a popup. I can't find a
way to "name" or call the popup from the dialog because using the name
frmPopup doesn't work in the Dialog Box.


Thanks.
 
You have two choices:

1)
Pass the name of the form/control to the dialog form, and then have it
set the value when the form closes. It is not clear if you need to design
this "prompt" form for general use, or a specify form????

So, if you do the above, then don't even bother with a dialog form, but use
a model form (they are complete different in use...while a dialog form is
model...a model form is not dialog at all).

So, assuming we JUST use a model form, then you can go:


docmd.OpenForm "slkfj",,,,,,"MyFormName, MyFieldName"

In the CoolPromptForm, in the on-load event, you can now go:

strFormtoUpdate = split(me.OpenArgs,",")(0)
strFieldToUpdate = split(me.OpenArgs,",")(1)

(I of couse assume strFormToUpdate and strFieldToUpdate are defined at the
module level for the CoolPromptForm)

Then, in the forms on-close event, you simply go:

forms(srFormToUpdate)(StrFieldToUPdate) = me.SomeTextBoxPrompt

So, the real answer is not to pass data, but in fact simply pass a forms
reference. You can even have the model form pick up the active form, and
even the active field on the previous form..and thus not even pass any field
refs if you wish.


The 2nd approach is the old fashioned approach were you call a form, wait
for response, and then the calling code continues and you grab the data. I
explain how to do this here:

http://www.attcanada.net/~kallal.msn/Dialog/Index.html
 
Back
Top