Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    PoorCadaver is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    68

    Problem with relations

    Hi!

    I have a number of tables that are related to each other. I e one computer belongs to one user. In the computers table I can choose a user from a drop box that's connected to a table containing all available users.
    The column in the computer table that contains information about the user is made so that the id(int) of the user is stored. So far so good and it's not too complicated.

    But when I create a form where I list all the computers with their related users, the user is showed in a drop box. When I change it to a text box (or create a new one) it won't show the username, but the user id (primary key).



    How do I solve this? Feels like it shouldn't be too difficult...

    Thanks!

    Jonas
    Last edited by PoorCadaver; 10-17-2011 at 03:19 AM. Reason: Changed title

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Hi Jonas

    I assume that the form is currently bound to the "Computers" table.
    Create a query with the "Computers" table and the "Users" table joined by the UsersID fields in each table and bind the form to this query. The User's Name field will then be available to use as the Control Source of a text box on the form.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    PoorCadaver is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    68
    When I create the query (using wizard), do I need to add every column in both tables?

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    You can, but you don't need to. You need the fields that you want on the form.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    PoorCadaver is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    68
    I have tried now, but then I realized that it can't work. You see, in reality I have more drop boxes in the particular form/table. I'm showing similar information from many tables, so I can't bind the form to just one table, right?

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Create a query that combines all the tables and bind the form to that query.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    PoorCadaver is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    68
    I'm sorry, but how do I bind it?

  8. #8
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Use the query as the Record Source for the form.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  9. #9
    PoorCadaver is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    68
    Two things didn't work... First of all, the form now only shows one (1) post and not everyone in the computer table. Second, it still displays the Id and not the name =(

  10. #10
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Ok

    Can you post a copy of your db?
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  11. #11
    PoorCadaver is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    68
    This is a stripped example version.
    As you can see in the form, the users names are replaced with their Id...
    So the big $1.000.000 question is: how do I get the names there instead? =)

    Jonas

  12. #12
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Like this?
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  13. #13
    PoorCadaver is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    68
    What did you do???

  14. #14
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    In the last db I changed the Record Source property of the form from the name of a table (Computers) to an SQL statement (an unsaved query)
    Take a look at the attached db.
    In this I have created a second form (Comp2) using a Saved query (qryComp2) as the Record Source of the form.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  15. #15
    PoorCadaver is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    68
    Ok, thanks a lot! I will try this out and see if I get it =)

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Confusion with table relations
    By BusDriver3 in forum Database Design
    Replies: 13
    Last Post: 08-21-2011, 01:48 PM
  2. Combining tables and keeping relations
    By Bangsadrengur in forum Access
    Replies: 7
    Last Post: 07-28-2011, 08:12 AM
  3. table relations & primary key
    By mwabbe in forum Access
    Replies: 9
    Last Post: 08-19-2010, 10:09 AM
  4. one to one relations
    By crackpot in forum Database Design
    Replies: 2
    Last Post: 08-18-2010, 09:39 AM
  5. two relations to one table?
    By kannuberg in forum Forms
    Replies: 19
    Last Post: 09-27-2009, 11:25 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