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]
SteveL13Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You must refer to the Subform differently:

Forms!YourMainForm.YourSubformCONTROLName.Form.txtID

Note too that a Default Value is only set for New Records.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hnasrCommented:
One way:
      Use the OpenArgs parameter in the OpenForm command.

     DoCmd.OpenForm "subfrmPlayerNotes", acNormal, , , acFormAdd, acWindowNormal, txtID.Value

    In Open event of form3

    txtID = Me.OpenArgs

Onother way:
    Declare a global variable gTemp in a module as Variant

    Private Sub txtID_Click()
        gTemp = txtID.value
        ....
   End Sub

    And in Form3 Open event
        txtID = gTemp
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
So I'm curious - which way did you end up doing this?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

SteveL13Author Commented:
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.
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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.
0
SteveL13Author Commented:
Thank you for the valuable information.  I do appreciate it.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.