VBA Code to copy value?

  • Thread starter Thread starter James
  • Start date Start date
J

James

I have been working on a form that has a subform
displaying data from a query. I would like to click a
button and transfer the SSN on the main form to a selected
record in the subform.
I've used code to do the event procedure on a button on
the subform, only I do not know how to ID the main form in
the code to tell it where to pull the value from.

SSN.text = Text14.text

How do I code Text14's location on the main form?

Thanks!
 
James said:
I have been working on a form that has a subform
displaying data from a query. I would like to click a
button and transfer the SSN on the main form to a selected
record in the subform.
I've used code to do the event procedure on a button on
the subform, only I do not know how to ID the main form in
the code to tell it where to pull the value from.

SSN.text = Text14.text

How do I code Text14's location on the main form?

SSN.text = Me.Parent.Text14.text

But, why are you using the Text property?? Is your VB
background showing? ;-) In Access, the Text property is
only useful during data entry for the text box. You should
be using the Value property instead:

Me.SSN.Value = Me.Parent.Text14.Value

Since Value is the default property for controls, you do not
need to actually specify it.

Me.SSN = Me.Parent.Text14

is the usual way to write that assignment. Technically, the
Me object is not needed either, but using it will
disambiguate the control from a variable of the same name.
 
Back
Top