Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

Trying to populate vale of a field in a sub-form with the value of a field on a forms sub-form

I have a hyperlink field in a sub-form or a main form.  When the user clicks the hyper link I have a 3rd form opening and want a field on that 3rd form to populate with the value of the clicked hyperlink.

Here is my code that opens the 3rd form which works fine...


Private Sub txtID_Click()

    If DCount("*", "tblPlayerNotes", "PlayerId=" & Me.txtPlayerID) > 0 Then
        DoCmd.OpenForm "subfrmPlayerNotes", acNormal, , "[PlayerID]=" & Me.txtID, , acWindowNormal
        DoCmd.Restore
    Else
        DoCmd.OpenForm "subfrmPlayerNotes", acNormal, , , acFormAdd, acWindowNormal
        DoCmd.Restore
    End If

End Sub

Open in new window


And here is my default value syntax for the field on the 3rd form which isn't working.

=[Forms]![subfrmTeamsPlayersByDivisionDS]![txtID]
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
So I'm curious - which way did you end up doing this?
Avatar of SteveL13

ASKER

Your way.  I am still trying to find out how to refer to forms and their subforms and other subforms.  I stumble over that every time.
Just remember that a Subform is ALWAYS in a Subform Control - so just like every other Control on a Form, you must first refer to the Control, and you can then refer to other properties/methods/attributes of that control.
Thank you for the valuable information.  I do appreciate it.