Grab the first field of selected Row in subform and Display it

Hello All,

I have a simple form and within that form there is a sub form. I want to set up an main form (On Open)  event so that when the main form opens up, it can get the value of  filed1 of the selected row  of sub form value and display it…can anybody help. I got confused with many examples in the internet with very long codes.  Please assist.

Thank you
RayneAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
COACHMAN99Connect With a Mentor Commented:
if you are working with a main and sub form then place the following code in the sub form (click event) - no global variable. (vvv = your field)

Private Sub Form_Click()
Forms("frmMain").Text3 = vvv
End Sub
0
 
COACHMAN99Commented:
Is the main form a 3rd form? and will the row be selected beforehand?
It may be easier to have a global variable and populate it when the row is selected.
e.g.
on subform click event
 gVar = vvv

and on main form load
 fieldX = gvar
0
 
RayneAuthor Commented:
Hello COACHMAN99

Is the main form a 3rd form? and will the row be selected beforehand? - probably, I guess. Like when you open a main form, the very first row of the sub form is selected by default, isn't it?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
COACHMAN99Commented:
Private Sub Form_Click()
Forms("frmMain").Text3 = vvv
End Sub
0
 
RayneAuthor Commented:
Is using a global variable is a good approach?
0
 
RayneAuthor Commented:
Perfection to THE Ultimate,

Thank you Sire, your saved my drowning boat, thank you thank you :)
0
 
COACHMAN99Commented:
glad I could help :-)
0
All Courses

From novice to tech pro — start learning today.