Results 1 to 3 of 3
  1. #1
    sahm is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    9

    Access 2010 Get Multiple Related Records from a Table

    Hi,

    I have the following code which works fine for getting ONE record based on "Job_Number" value and storing it in another control. However, I have more than one record which have the same "Job_Number" and I would like to get all of them and store them in that control. I know I need something like a Loop until I get all of them but not sure how to do it.

    ================================================
    Dim strBill As String
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset
    Set dbs = CurrentDb


    Set rst = dbs.OpenRecordset("SELECT Containers.* FROM Containers WHERE Containers.Job_Number = " & Me!Job_Number)

    strBill = rst.Fields(3).Value


    Marks_and_Numbers.Value = strBill




    rst.Close
    Set rst = Nothing
    Set dbs = Nothing


    ================================================

    Any ideas how to achieve that.




    Many thanks.
    Sahm

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    You want to store multiple values into one field in table? Why? That is poor design.

    While Not rst.EOF
    strBill = strBill & ", " & rst.Fields(3).Value
    rst.MoveNext
    Wend
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    sahm is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    9
    Many thanks June7.

    The code works fine.

    I need this to put the all values in a Memo field as text info only.

    Thanks again.

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

Similar Threads

  1. Replies: 18
    Last Post: 07-19-2018, 05:05 PM
  2. Replies: 9
    Last Post: 01-26-2013, 11:06 PM
  3. VBA Across Multiple Records (Access 2010)
    By Scorpio11 in forum Access
    Replies: 3
    Last Post: 03-28-2012, 11:33 AM
  4. Replies: 1
    Last Post: 04-02-2011, 11:55 AM
  5. Table related to multiple tables by single ID
    By MrTumnus in forum Access
    Replies: 1
    Last Post: 11-17-2009, 02:05 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