Forum Discussion

ebenton's avatar
ebenton
Copper Contributor
Jun 03, 2021
Solved

Getting a field from another form

Hey Guys,   I have a survey attached to a user profile, and I am trying to connect it to a table with recommendations based on the user's input.  I am only just started learning about Access 3 week...
  • George_Hepworth's avatar
    George_Hepworth
    Jun 03, 2021

    ebenton 

     

    Your code passes a SQL Select statement to the second form. You ONLY need to pass the appropriate fields for the person and for the recommendation. 

    In addition, the second line is redundant. Your first line opens the recommendations form already filtered to that person.

     

    You can pass both filtering values in a single line, something like this.


    SurID = DLookup ("SurID", "Surveys", "Survey.PersonID_fk = " & Me.PersonID)
    DoCmd.OpenForm "Recommendations",,, "PersonID_fk = " & Me.PersonID & " AND SurveyID_FK = " & SurID

Resources