Code Help

G

Gabe

I currently have a button that takes the values of some parent form fields
and copies them to subform1 (a history form). However, I want to take the
value of subform2 (a query subform within the same parent form), and put it
in subform1. The button is located in subform1 and the code is in the (On Dbl
Click), here's the code I have been using:

Private Sub AddCurrent_DblClick(Cancel As Integer)
Me.EmpName = Me.Parent.EmpName
End Sub

So instead of (Me.Parent.EmpName), how can I get it to take subform2? I
tried (Me.subform1.EmpName), but it didn't work...

Thanks,
~Gabe
 
J

Jeff Boyce

Gabe

If I'm understanding your description, you are trying to copy values from
one table to another (I'm assuming that your forms and subforms are based on
respective tables). If this is accurate, you may want to rethink your table
structure. In a well-normalized relational database, you don't need to copy
values from one table to another.

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or psuedocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
M

Marshall Barton

Gabe said:
I currently have a button that takes the values of some parent form fields
and copies them to subform1 (a history form). However, I want to take the
value of subform2 (a query subform within the same parent form), and put it
in subform1. The button is located in subform1 and the code is in the (On Dbl
Click), here's the code I have been using:

Private Sub AddCurrent_DblClick(Cancel As Integer)
Me.EmpName = Me.Parent.EmpName
End Sub

So instead of (Me.Parent.EmpName), how can I get it to take subform2? I
tried (Me.subform1.EmpName), but it didn't work...


To get a value from subform2's current record, try using
something more like:

Me.EmpName = Me.Parent.subform2.Form.EmpName
 
B

Barry A&P

I am not sure if you are referring to a specific record on subform 2 and I am
by no means an expert but try
Me!EmpName = Forms!Parent!subform2.EmpName ??

Barry
 
J

Jack Leach

From subform1, you will first need to reference the Parent, and then the
Subform that is on the parent...

Me.Parent!Subformcontrol.Form.empname

I think I have the bang (!) right, not positive though... they always
confuse me. Luckily, some folks at mvps.org have put together a handy table
for figuring out stuff like this.

http://www.mvps.org/access/forms/frm0031.htm

hth
--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 

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