Data from one form to the other. Help Please!!!

  • Thread starter Thread starter Ayo
  • Start date Start date
A

Ayo

Here is what I have:
I have 2 forms. The 1st has a cmbBox and a button. The 2nd form has a
txtBox, a button and a Subform.
This is what I want to accomplish:
I want to select a value into the cmbBox on the 1st form and click the
button. This is suppose to close the 1st form, open the 2nd form and assign
the value from the cmbBox the txtBox on the 2nd form.

Forms![Invoice by Vendor].txtReviewer.Text = Me.cmbVendor.Text
This is part of the code I am using to try a do this, but I am having a
problem and I don't know what I am doing wrong.

Help Please
 
Ayo said:
Here is what I have:
I have 2 forms. The 1st has a cmbBox and a button. The 2nd form has a
txtBox, a button and a Subform.
This is what I want to accomplish:
I want to select a value into the cmbBox on the 1st form and click the
button. This is suppose to close the 1st form, open the 2nd form and
assign
the value from the cmbBox the txtBox on the 2nd form.

Forms![Invoice by Vendor].txtReviewer.Text = Me.cmbVendor.Text
This is part of the code I am using to try a do this, but I am having a
problem and I don't know what I am doing wrong.

Help Please

As usual in Access there's more than one way to do this, but my preferred
method would be to pass the value of cmbVendor in the OpenForm's OpenArgs
parameter:

DoCmd.OpenForm "Invoice by Vendor", OpenArgs:=Me.cmbVendor.Value

Then in the OnLoad event of Invoice by Vendor:

Me.txtReviewer.Value = Me.OpenArgs

(incidentally, don't use the .Text property in this kind of context, because
a) the control must have the focus in order to use this property and b) the
property contains what is currently typed into the control, not the updated
value. Use the .Value property instead)
 
Thanks agian.

Stuart McCall said:
Ayo said:
Here is what I have:
I have 2 forms. The 1st has a cmbBox and a button. The 2nd form has a
txtBox, a button and a Subform.
This is what I want to accomplish:
I want to select a value into the cmbBox on the 1st form and click the
button. This is suppose to close the 1st form, open the 2nd form and
assign
the value from the cmbBox the txtBox on the 2nd form.

Forms![Invoice by Vendor].txtReviewer.Text = Me.cmbVendor.Text
This is part of the code I am using to try a do this, but I am having a
problem and I don't know what I am doing wrong.

Help Please

As usual in Access there's more than one way to do this, but my preferred
method would be to pass the value of cmbVendor in the OpenForm's OpenArgs
parameter:

DoCmd.OpenForm "Invoice by Vendor", OpenArgs:=Me.cmbVendor.Value

Then in the OnLoad event of Invoice by Vendor:

Me.txtReviewer.Value = Me.OpenArgs

(incidentally, don't use the .Text property in this kind of context, because
a) the control must have the focus in order to use this property and b) the
property contains what is currently typed into the control, not the updated
value. Use the .Value property instead)
 
Back
Top