Passing data from one form to another

G

Guest

Hello I have a form called frmMaindB and it has 5 text boxes on it
(txtEmployeeTime, txtDTRegular, txtDTReason1, txtDTReason2, txtDTMaintenance)
when I double click on the text box it opens up a form named
frm_DecimalConversion. On this form I have two text boxes one box I enter
data into and the other calculates or converts the data to a decimal. The box
that converts the data is called txtDecimal. Then I have a close button whic
I want to use to close the pop up form and incert the data into the text box
I double clicked in to get the data needed. I have read that I need to use
the OpenArgs. But I have no clue how to get started? Someone told me to use
this in the box I double click into to get the pop up (Docmd.OpenForm
"frm_DecimalConversion" , , , , , , 1) and to use a diferent number like
2,3,4,5 for the other text boxes I double click to get te pop up then they
told me to do this:

Then wherever you're running your code in your popup to populate the main
form textbox, use

Select Case Me.OpenArgs

Case 1 'this will be the textbox that you used the number 1
Forms!frmMaindB!TextBox1 = Me.txtDecimal

Case 2 'this will be the textbox that you used the number 2
Forms!frmMaindB!TextBox2 = Me.txtDecimal


Can someone please explain or give me an example of what I need to do
because I dont quite understand....Thanks!
 
G

Guest

Chad,

Just as an alternative. Have you tried the following:

You have code behind the button to close. Right before you close enter the
following:

forms!frmMainDB![yourfield]=me.txtDecimal
DoCmd.Close acForm, me.name

Where [yourfield] is the field where the answer should come.

hth
 
G

Guest

This will give me the same thing I have I think. I want to use the close
button and have it update the text box that I double clicked to get the pop
up to open. Thanks!

Maurice said:
Chad,

Just as an alternative. Have you tried the following:

You have code behind the button to close. Right before you close enter the
following:

forms!frmMainDB![yourfield]=me.txtDecimal
DoCmd.Close acForm, me.name

Where [yourfield] is the field where the answer should come.

hth
--
Maurice Ausum


Chad said:
Hello I have a form called frmMaindB and it has 5 text boxes on it
(txtEmployeeTime, txtDTRegular, txtDTReason1, txtDTReason2, txtDTMaintenance)
when I double click on the text box it opens up a form named
frm_DecimalConversion. On this form I have two text boxes one box I enter
data into and the other calculates or converts the data to a decimal. The box
that converts the data is called txtDecimal. Then I have a close button whic
I want to use to close the pop up form and incert the data into the text box
I double clicked in to get the data needed. I have read that I need to use
the OpenArgs. But I have no clue how to get started? Someone told me to use
this in the box I double click into to get the pop up (Docmd.OpenForm
"frm_DecimalConversion" , , , , , , 1) and to use a diferent number like
2,3,4,5 for the other text boxes I double click to get te pop up then they
told me to do this:

Then wherever you're running your code in your popup to populate the main
form textbox, use

Select Case Me.OpenArgs

Case 1 'this will be the textbox that you used the number 1
Forms!frmMaindB!TextBox1 = Me.txtDecimal

Case 2 'this will be the textbox that you used the number 2
Forms!frmMaindB!TextBox2 = Me.txtDecimal


Can someone please explain or give me an example of what I need to do
because I dont quite understand....Thanks!
 
G

Guest

I just looked at the on click of my close button and yes it will do the same
thing. I need it to be able to update the txt box that I double clicked from
to get the form and it could be one of five text boxes. So something would
have to know which box needs updated with the answer from my pop up form.
Here is what I have in my close button but like I said it only works for the
one text box on my frm_MaindB.

Private Sub cmdCloseDecimalConversion_Click()
On Error GoTo Err_cmdCloseDecimalConversion_Click

Forms!frmMaindB!txtDTRegular = Me.txtDecimal

DoCmd.Close

Exit_cmdCloseDecimalConversion_Click:
Exit Sub

Err_cmdCloseDecimalConversion_Click:
MsgBox Err.Description
Resume Exit_cmdCloseDecimalConversion_Click

End Sub
 

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