Use Popup to Populate Control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to double click a textbox (on a continuous form), open a popup
that is used to calculate the value that should be placed in the textbox,
then update the textbox with this calculate value (by clicking an OK button).

Opening the popup and doing the calculation in the form is easy. The result
is calculated in a textbox on this popup. How do you then pass this value
pack to the textbox that was originally double clicked?

Thanks

Dave
 
You give any details about how you are opening the popup form. I am guessing
that you are opening it in 'dialog' mode using the acDialog option of the
WindowMode paremeter of
docmd.Openform. If so, you already know that when used, the code in the
first form will pause until the second form (the one being opened) is either
hidden or closed. With this in
mind, on the second form put an 'OK' button which the user clicks to
indicate that a selection has been made (you could do the same thing with
the double click event on the product control). The code behind the click
event of the OK button should hide the form (rather than close it). Once the
second form is hidden, the code in original form will resume and can use the
value in the control on the now hidden form to set the value of the control
on your main form. Then the second form is closed by the first form. Here's
some sample code:

Code on first Form:

Private Sub Command19_Click()
DoCmd.OpenForm "form2", , , , , acDialog
Me.MyControl = Forms!form2.MyControlCalc
DoCmd.Close acForm, "form2"
End Sub


Code on second form:

Private Sub cmdOK_Click()
Me.Visible = False
End Sub
 
Thanks, I'll give it a go.

Sandra Daigle said:
You give any details about how you are opening the popup form. I am guessing
that you are opening it in 'dialog' mode using the acDialog option of the
WindowMode paremeter of
docmd.Openform. If so, you already know that when used, the code in the
first form will pause until the second form (the one being opened) is either
hidden or closed. With this in
mind, on the second form put an 'OK' button which the user clicks to
indicate that a selection has been made (you could do the same thing with
the double click event on the product control). The code behind the click
event of the OK button should hide the form (rather than close it). Once the
second form is hidden, the code in original form will resume and can use the
value in the control on the now hidden form to set the value of the control
on your main form. Then the second form is closed by the first form. Here's
some sample code:

Code on first Form:

Private Sub Command19_Click()
DoCmd.OpenForm "form2", , , , , acDialog
Me.MyControl = Forms!form2.MyControlCalc
DoCmd.Close acForm, "form2"
End Sub


Code on second form:

Private Sub cmdOK_Click()
Me.Visible = False
End Sub

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

I would like to double click a textbox (on a continuous form), open a
popup that is used to calculate the value that should be placed in
the textbox, then update the textbox with this calculate value (by
clicking an OK button).

Opening the popup and doing the calculation in the form is easy. The
result is calculated in a textbox on this popup. How do you then pass
this value pack to the textbox that was originally double clicked?

Thanks

Dave
 
Works perfectly. Thanks.

Sandra Daigle said:
You give any details about how you are opening the popup form. I am guessing
that you are opening it in 'dialog' mode using the acDialog option of the
WindowMode paremeter of
docmd.Openform. If so, you already know that when used, the code in the
first form will pause until the second form (the one being opened) is either
hidden or closed. With this in
mind, on the second form put an 'OK' button which the user clicks to
indicate that a selection has been made (you could do the same thing with
the double click event on the product control). The code behind the click
event of the OK button should hide the form (rather than close it). Once the
second form is hidden, the code in original form will resume and can use the
value in the control on the now hidden form to set the value of the control
on your main form. Then the second form is closed by the first form. Here's
some sample code:

Code on first Form:

Private Sub Command19_Click()
DoCmd.OpenForm "form2", , , , , acDialog
Me.MyControl = Forms!form2.MyControlCalc
DoCmd.Close acForm, "form2"
End Sub


Code on second form:

Private Sub cmdOK_Click()
Me.Visible = False
End Sub

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

I would like to double click a textbox (on a continuous form), open a
popup that is used to calculate the value that should be placed in
the textbox, then update the textbox with this calculate value (by
clicking an OK button).

Opening the popup and doing the calculation in the form is easy. The
result is calculated in a textbox on this popup. How do you then pass
this value pack to the textbox that was originally double clicked?

Thanks

Dave
 
Back
Top