Passing values from Child to parent (1 Viewer)

Super Suarez

Registered User.
Local time
Today, 14:02
Joined
Jul 10, 2013
Messages
36
Hi

I have a variable tempnum on a subform which I want to pass into a textbox on the main parent form. I cant seem to get it right. Here's my code

Me.Parent.Parent![List num].Value = tempnum

Hope you can help
 

pr2-eugin

Super Moderator
Local time
Today, 22:02
Joined
Nov 30, 2011
Messages
8,494
Try
Code:
Me.Parent!
[List num] = tempnum
 

Super Suarez

Registered User.
Local time
Today, 14:02
Joined
Jul 10, 2013
Messages
36
Thanks but no that's not working.
 

jdraw

Super Moderator
Staff member
Local time
Today, 17:02
Joined
Jan 23, 2006
Messages
15,394
What exactly does "not working" mean?

You could do some debugging.

Code:
 Debug.print Me.Parent![List num]
 Debug.print "Tempnum  " & tempnum
.....
Me.Parent![List num] = tempnum [COLOR="Green"]'your original line[/COLOR]
 Debug.print Me.Parent![List num]
 

Super Suarez

Registered User.
Local time
Today, 14:02
Joined
Jul 10, 2013
Messages
36
It's not writing a value to my [List num] textbox on my main form.

I've tried msgbox() instead of debug.print but again nothing except for msgbox("Tempnum " & tempnum) where it does output tempnum.

it's rather bizarre
 

jdraw

Super Moderator
Staff member
Local time
Today, 17:02
Joined
Jan 23, 2006
Messages
15,394
Can you post a copy of you data base (no confidential info)?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 17:02
Joined
Feb 19, 2002
Messages
43,477
You do realize that there is a 1-many relationship between parents and children and it doesn't make any sense to poke child data into a parent record. You would actually need to be positioned on a child record and do something to make your code run before it would update the parent record.
 

Super Suarez

Registered User.
Local time
Today, 14:02
Joined
Jul 10, 2013
Messages
36
Well in the end it worked via the following:-

[List num] = tempnum

Which I thought was a bit strange. I have got my terminology right here for parents and child. The main form has a button which opens a further form (which I believe is the child) right? It is in this child form that I have the above code which then updates the main form.
 

Users who are viewing this thread

Top Bottom