Results 1 to 6 of 6
  1. #1
    Nigel1500 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    3

    I want data from two tables on the same control.

    Hello,

    I'm new to MS Access 2010. I have a situation where I have a table of names and a table of aliases that I'd like to display in one continuous form. They are linked as follows and one name can have many aliases:

    tbl_Names:
    --------------
    ID as AutoNumber (primary key)
    Name as Text


    Sample data:
    1 Alan
    2 Ben Smith
    3 Charlie L
    4 Darren C Langworthy
    5 Ed Liu

    tbl_Aliases:
    --------------
    ID as AutoNumber
    Name_ID (tbl_Names one to many relationship)
    Alias as Text


    Sample data:
    1 3 Charlie
    2 1 Big Al
    3 5 The Chinaman
    4 2 The Terminator
    5 1 All Over It
    6 4 Dags
    7 2 Afterglow
    8 5 On Your Case
    9 3 Charles

    In a Text Box, I would like to display the merged fields of tbl_Name(Name) and tbl_Alias(Alias) sorted alphabetically, with Names formatted differently to Aliases as follows:
    Afterglow
    Alan
    All Over It
    Ben Smith
    Big Al
    Charles
    Charlie
    Charlie L
    Dags


    Darren C Langworthy
    Ed Liu
    On Your Case
    The Chinaman
    The Terminator
    I'm just not sure how to tackle this. Any advice appreciated.

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383

    Two Tables, Same Control

    You can Concatenate the two fields together. In your query grid this would be an example: Of course you need both tables in your query.

    FullName: [FirstName]&" "& [LastName]
    HTH

    EDIT: Unsure why you would do this. Or of your form setup. Is this just for display purposes? Here is a screenshot of an example.
    I used a Cartesian and a continuous subform for the example.
    Attached Thumbnails Attached Thumbnails Aliases.jpg  
    Last edited by burrina; 08-06-2014 at 12:16 AM. Reason: Further Code Example

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Another option is to use a Union query. Can't have special formatting for certain words and not others.
    Maybe a 2nd field with a "+" for the alias.

    Note that "Name" is a reserved word and shouldn't be used as object names.
    Here is a list of reserved words : http://allenbrowne.com/AppIssueBadWord.html

  4. #4
    Nigel1500 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    3
    Quote Originally Posted by burrina View Post

    EDIT: Unsure why you would do this. Or of your form setup. Is this just for display purposes?
    Hi burrina,

    Thanks for the prompt reply. The aim is to be able to select a person, or alias, from the same list and open a sub-form to enter data. Such a situation could be linked to the management of a forum ... illegal bikie gang ... or a secret spy agency. So, I'd like to be able to select, 007, Bond, James Bond, <other alias> ... etc.

  5. #5
    Nigel1500 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    3
    Quote Originally Posted by ssanfu View Post
    Another option is to use a Union query. Can't have special formatting for certain words and not others.
    Maybe a 2nd field with a "+" for the alias.

    Note that "Name" is a reserved word and shouldn't be used as object names.
    Here is a list of reserved words : http://allenbrowne.com/AppIssueBadWord.html
    Hi ssanfu,

    Thanks for the prompt reply. I will try a Union query. Something like this:
    http://stackoverflow.com/questions/4...ss-union-query

    But do I build the query under Form/Data/Record Source, or do I use an event?

    Also, your idea of an extra field is an excellent idea. I might be able to use conditional formatting. Will get back to you with my results soon.

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Yep, something like that. You will have to create a new query and type in the SQL..... query builder can't handle it.

    Really fuzzy on what you are trying to do, but...
    That query is bound to a list box. Then use the list box double click to open another form...?????

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

Similar Threads

  1. Replies: 5
    Last Post: 03-31-2014, 02:26 PM
  2. Replies: 17
    Last Post: 08-21-2013, 12:52 PM
  3. tab control and tables
    By moona in forum Forms
    Replies: 5
    Last Post: 07-19-2013, 03:25 PM
  4. 1 text box control, from two tables
    By mike02 in forum Forms
    Replies: 3
    Last Post: 06-21-2013, 01:51 PM
  5. activex control (ado data control)
    By metokushika in forum Access
    Replies: 4
    Last Post: 11-07-2011, 12:45 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