Results 1 to 4 of 4
  1. #1
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    281

    Trying to get query results to populate a textbox


    Hello ~

    I am trying to get the attribute of a specific field of a query to populate a TextBox

    So far I have:
    Code:
    Private Sub Text70_AfterUpdate()
    
    Dim strOpenSQL As String
       
    strOpenSQL = "SELECT tbl_AssocInfo.DB_ID, tbl_AssocInfo.First_Nm, tbl_AssocInfo.Last_Nm, tbl_AssocInfo.Hire_Dt " & _
                   "From tbl_AssocInfo " & _
                   "WHERE (((tbl_AssocInfo.DB_ID)=[Forms]![frmAttendanceNotice]![Text70]));"
    DoCmd.OpenQuery "QryHireDateTest", , acReadOnly
    '[Forms]![frmAttendanceNotice]![Text72] = tbl_AssocInfo.Hire_Dt  <--------------
    End Sub
    I have also tried using the following in the textbox Control Source

    =DLookUp("[Hire_Dt]",[QryHireDateTest])

    Nothing but errors

    There will always be just one result of the search as the DB_ID is a PK

    Thanks as always...

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Each argument is a string:

    =DLookUp("[Hire_Dt]","[QryHireDateTest]")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    281
    Brilliant!! Thanks Paul!!

    Works Great!

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 09-12-2017, 12:41 AM
  2. Replies: 9
    Last Post: 05-09-2017, 06:46 PM
  3. Replies: 3
    Last Post: 01-14-2014, 03:56 PM
  4. Dsplaying query results in a textbox
    By sevanty7 in forum Access
    Replies: 2
    Last Post: 05-08-2013, 09:00 AM
  5. Populate Table with query results
    By sparkyboy2406 in forum Queries
    Replies: 1
    Last Post: 02-23-2010, 03:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums