Results 1 to 4 of 4
  1. #1
    cowboy is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    291

    one to many relationship?

    I have a list of people in a list box and when I select someone in the list box I want however many addresses that person has in another list box or sub form. What is the best way to set this up?



    I was trying to do this by having a query that got the unique identifier that matches the tables but when I tried to pass the parameter it didnt do anything, just displayed a blank query .... the code is:

    PARAMETERS [Forms]![MainForm]![lstPeople]![Column(0)] IEEEDouble;
    SELECT Addresses.AdrID, Addresses.PID, Addresses.Address, Addresses.City, Addresses.State, Addresses.ZipCode
    FROM Addresses
    WHERE (([PID] = [Forms]![MainForm]![lstPeople]![Column(0)]));

    Then I was going to try to set another list box to get its row source from the query. This didnt work the way I wanted, am I on the right track or way off?

  2. #2
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    Looks like all you need to do is change [Column(0)] to .Column(0) to fix the problem.

    Code:
    SELECT Addresses.AdrID, Addresses.PID, Addresses.Address, Addresses.City, Addresses.State, Addresses.ZipCode
    FROM Addresses
    WHERE ([PID] = [Forms]![MainForm]![lstPeople].Column(0));

  3. #3
    cowboy is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    291
    PARAMETERS [Forms]![MainForm]![lstPeople]![Column(0)] IEEEDouble;
    SELECT Addresses.AdrID, Addresses.PID, Addresses.Address, Addresses.City, Addresses.State, Addresses.ZipCode
    FROM Addresses
    WHERE (([PID]=Forms!MainForm!lstPeople.Column(0)));

    Gives me an error: "Undefined function 'Forms!MainForm!lstPeople.Column' in expression."

    PARAMETERS [Forms]![MainForm]![lstPeople].Column(0) IEEEDouble;
    SELECT Addresses.AdrID, Addresses.PID, Addresses.Address, Addresses.City, Addresses.State, Addresses.ZipCode
    FROM Addresses
    WHERE (([PID]=Forms!MainForm!lstPeople.Column(0)));


    Gives me an error: "Syntax error in PARAMETER clause."

  4. #4
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    Well, I know virtually nothing about the PAREMETERS statement but here goes. . .

    Code:
    PARAMETERS [Forms]![MainForm]!lstPeople Integer;
    SELECT Addresses.AdrID, Addresses.PID, Addresses.Address, Addresses.City, Addresses.State, Addresses.ZipCode
    FROM Addresses
    WHERE (([PID]=[Forms]![MainForm]!lstPeople));

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

Similar Threads

  1. Relationship
    By pcandns in forum Access
    Replies: 2
    Last Post: 04-01-2009, 09:32 AM
  2. Many-to-Many Relationship
    By Carolyn1 in forum Database Design
    Replies: 0
    Last Post: 09-25-2006, 02:04 PM
  3. Many to Many relationship
    By Marlie in forum Database Design
    Replies: 6
    Last Post: 08-18-2006, 01:49 PM
  4. one to many relationship
    By pe_z in forum Database Design
    Replies: 2
    Last Post: 02-17-2006, 10:44 PM
  5. MAY TO MANY RELATIONSHIP
    By fadone in forum Database Design
    Replies: 2
    Last Post: 12-20-2005, 09:03 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