Results 1 to 3 of 3
  1. #1
    fsask2013 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Feb 2013
    Posts
    2

    Report field: Pull data from different table based on value in different field

    Haven't done much with Access in a long time.

    I have a Report that I want to add a field to. It's a text box meant to display some data from a different table other than the one the Report is tied to.

    The table is use is called "PrimaryData" and the second table is called "NamesOnly"

    Both tables have a field called "Username" and the second table only has a field called "Companyname"

    I want this Report box to display the value (it's a string..) of Companyname from the second table, based on what the Username is.

    I think the basic idea for the text box Control Source is:

    =[NamesOnly]![Companyname]

    but how to specify the condition, "WHERE the Username on the same record determines which [Companyname] to display..."

    Sorry if this is unclear. I have some decent experience with SQL, but am really not familiar with how to express this stuff in Access.



    TIA for your suggestions!

  2. #2
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254
    fsask2013 -

    Assuming [Username] is text and the field [Username] is in the NamesOnly table?, you could try something like...

    =Dlookup("[CompanyName]","NamesOnly","[Username]= '" & Me![Username] & "'")

    All the best,

    Jim

  3. #3
    fsask2013 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Feb 2013
    Posts
    2
    Thank you, I'll try that approach. I temporarily solved the problem by running modifying the large Excel file that I imported into the Access table for the data. I'd prefer the Access-only route, as I feel that maintaining 2 Access tables is simpler than having to deal with the Excel sheets.

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

Similar Threads

  1. Replies: 3
    Last Post: 02-06-2013, 10:00 PM
  2. Replies: 5
    Last Post: 11-01-2012, 09:26 AM
  3. Replies: 5
    Last Post: 12-22-2011, 11:01 AM
  4. Replies: 1
    Last Post: 08-31-2011, 04:03 PM
  5. Selecting a corresponding table field based on text field.
    By michaeljohnh in forum Programming
    Replies: 5
    Last Post: 10-08-2010, 10:33 AM

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