Calling a field in a subform from another subform

johndoomed

VBA idiot
Local time
Today, 03:48
Joined
Nov 4, 2004
Messages
174
Hi guys!

I'm having problems with transfering data from one subform to another. On a button in "subform1" I've tried this code:

var1 = Me.Parent.subform2.fieldname
(I've also tried ...fieldname.Value)

I just get "can't find.."

Any ideas?
 
In the controlsource of a control in the first subform, try invoking the expression builder. Doubleclick through forms, loaded forms, the main form, the appropriate subform and then the actual control. This should give a reference something either like

forms![MainFormName]![SubFormControlName].Form![txtControl]

or

Parent![SubFormControlName].Form![txtControl]

Amend to

Me.Parent!SubFormControlName.Form!txtControl

You might want to read http://www.mvps.org/access/forms/frm0031.htm and/or http://support.microsoft.com/?kbid=209099. What is sometimes the challenge here, is that what is used in the reference, is the subform control name, which can differ from the subform name.
 
Takk så mye RoyVidar! (That would be "thanks" in norwegian)

That solved my problem!
 
Last edited:
Yay for expression builder - couldn't remember the syntax for this one but this helped me remember :D

Ruth
 

Users who are viewing this thread

Back
Top Bottom