Using VBA SQL returned values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phytorion
    New Member
    • Feb 2007
    • 116

    Using VBA SQL returned values

    so my problem is I want to use the values returned from the below SQL to populate textboxes etc. on my form. Is there a way to assign these values(VALUE1,V ALUE2) to variables?

    Thanks,
    Eric

    Code:
     Dim strSQL As String
       
          strSQL = "SELECT A.VALUE1, A.VALUE2 FROM tblWORK_DETAIL A WHERE    A.BUILD_NAME='" & Me.cboBUILD_NAME.Value & "’ " & _
                     "AND A.WORK_DATE= (SELECT MAX(B.WORK_DATE)FROM tblWORK_DETAIL B" & _
                     "WHERE A.BUILD_NAME=B.BUILD_NAME" & _
                     "AND A.WORK_DATE=B.WORK_DATE"
         
     DoCmd.RunSQL.strSQL
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32645

    #2
    Typically, you would set the Record Source of the form to the SQL you require then all controls on the form can be bound to the fields returned.
    The Record Source can be changed dynamically on opening the form, or a filter can be applied (less design work) at invokation time of the form.

    Comment

    • phytorion
      New Member
      • Feb 2007
      • 116

      #3
      Originally posted by NeoPa
      Typically, you would set the Record Source of the form to the SQL you require then all controls on the form can be bound to the fields returned.
      The Record Source can be changed dynamically on opening the form, or a filter can be applied (less design work) at invokation time of the form.

      Thanks NeoPa i think that should work.

      Eric

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32645

        #4
        No worries Eric.
        Let us know how you get on with it :)

        Comment

        Working...