Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate Mainform with Subform Record

Status
Not open for further replies.

Oblvion

Programmer
Aug 24, 2009
8
CA
I want to select a Subform record using the Record Selector, then click a GoTo button on the Mainform to populate the Mainform with that selected Subform record. All records are controlled by MemberID.
 
I want to select a Subform record using the Record Selector, then click a GoTo button on the Mainform to populate the Mainform with that selected Subform record. All records are controlled by MemberID

You will have to explain this much better. Provide a discussion of the tables and queries used as your main form and subform recordsource. This seems really strange so explain well. Normally if a database is properly designed the subform contains liked "child" records. Therefore there should be no fields in the mainform record that are common to the subform. If the subform was not linked to the main form, then possibly there could be a case that made sense. However, since they are linked this does not make any sense to me.
 

the image shows my GoTo buttons.
the GoTo buttons work on the Mainform info of my Father, Mother and Spouse to show them.

problem: for the GoTo button to show Children info that's in the Subform. All records use the same MemberID and same fields.

if still doesn't make sense, i can send the whole database for you to solve the problem. database has the whole code that the GoTo buttons use.
 
I was confused when you say "populate the main form" you mean go to that record on the main form that exists in the subform. Populate usually denotes inputting data, but I think you mean move.

So it would be something like this (Untested so expect errors)

Assuming your field is "memberID"
Code:
 dim memID as string
 dim rs as dao.recordset
 dim strWhere as string
 'reference the selected member ID in subform
 memID = nz(me.subformcontrolName.form.memberID,"")
 if not memID = "" then
   strWhere = "[memberID] = '" & memID & "'"
   set rs = me.recordset
   rs.findfirst strWhere
 end if
 
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.findfirst "[MemberID] = '" & Me![Mother] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

The GoTo button to call my Mothers record.
Can you code it to call a Childrens record that has a Record Selector beside it?
 
OMG !!! I SOLVED IT...

Private Sub cmdGoToChildRecord_Click()

' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[MemberID] = '" & ChildrenSubform.Form![MemberID] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

End Sub

THANKS FOR YOUR DIRECTION MAJP - YOURE A GENIUS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top