Results 1 to 2 of 2
  1. #1
    CoachBarker is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    17

    Adding table to Query removes every 4th record

    I have a db made up of sample data, tblRentals holds the transactions for rental units.
    RentalIDPKStorageShedIDFKCustomerIDFKBeginningDateFKEndingDatePaymentDateRentalRateIDFKPaymentMadePaymentBalanceDuePaymentTypeIDFKCheckNumberCreditCardNameIDFKCreditCardNumberMoneyOrderNumberLateCharges

    If I build a query and run it with all the FK included I lose 3/4 (returns 55 of 219)of the records. I narrowed it down to the CreditCardName table. When I add this table records disappear.

    without CreditCardName table.
    Attachment 2038

    with CreditCardName table.
    Attachment 2037

    Code:
    SELECT tblRentals.RentalID, tblStorageUnits.StorageShedID, tblCustomers.CustomerID, tblRentals.BeginningDate, tblRentals.EndingDate, tblRentals.PaymentDate, tblRentalRate.RentalRate, tblRentals.PaymentMade, tblRentals.PaymentBalanceDue, tblPaymentType.PaymentType, tblRentals.CheckNumber, tblCreditCardType.CreditCardName, tblRentals.CreditCardNumber, tblRentals.MoneyOrderNumber, tblRentals.LateCharges
    FROM tblCreditCardType INNER JOIN (tblStorageUnits INNER JOIN (tblRentalRate INNER JOIN (tblPaymentType INNER JOIN (tblCustomers INNER JOIN tblRentals ON tblCustomers.CustomerID = tblRentals.CustomerID) ON tblPaymentType.PaymentTypeID = tblRentals.PaymentTypeID) ON tblRentalRate.RentalRateID = tblRentals.RentalRateID) ON tblStorageUnits.StorageShedID = tblRentals.StorageShedID) ON tblCreditCardType.CreditCardNameID = tblRentals.CreditCardNameID;
     
     
    SELECT tblRentals.RentalID, tblStorageUnits.StorageShedID, tblCustomers.CustomerID, tblRentals.BeginningDate, tblRentals.EndingDate, tblRentals.PaymentDate, tblRentalRate.RentalRate, tblRentals.PaymentMade, tblRentals.PaymentBalanceDue, tblPaymentType.PaymentType, tblRentals.CheckNumber, tblRentals.CreditCardNameID, tblRentals.CreditCardNumber, tblRentals.MoneyOrderNumber, tblRentals.LateCharges
    FROM tblStorageUnits INNER JOIN (tblRentalRate INNER JOIN (tblPaymentType INNER JOIN (tblCustomers INNER JOIN tblRentals ON tblCustomers.CustomerID = tblRentals.CustomerID) ON tblPaymentType.PaymentTypeID = tblRentals.PaymentTypeID) ON tblRentalRate.RentalRateID = tblRentals.RentalRateID) ON tblStorageUnits.StorageShedID = tblRentals.StorageShedID;
    relationships
    Attachment 2039

    I can attach an excel file with all the tables or if allowed a copy of the db. Any suggestions?

  2. #2
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    I didn't look at the attachment. But I can assure you that queries are never, technically, incorrect. The result may not be what you think it should - but they are never wrong.

    Generically: When you add a table to a query - depending on the relationship line between it and the other tables: it will reduce the record set because it will return only records that all share a common value ; or it can increase the record set for more or less the same reason.

    When you have multiple inner joins it become quite complicated. I would suggest that you partition your query. Because one can use a query in another query (as opposed to a table). This allows you to see the results step by step in running each query separately.

    Hope this helps.

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

Similar Threads

  1. Adding Sequential Values to Make-Table Query
    By obrien.robj in forum Queries
    Replies: 2
    Last Post: 08-25-2010, 12:55 PM
  2. Re: Adding a new record to a joined table
    By Mcdodre in forum Access
    Replies: 4
    Last Post: 06-30-2010, 12:07 PM
  3. Replies: 1
    Last Post: 03-29-2010, 04:11 AM
  4. Adding new column to make-table query
    By dtn118 in forum Access
    Replies: 2
    Last Post: 08-03-2008, 06:51 AM
  5. Adding a single record
    By kfoyil in forum Forms
    Replies: 2
    Last Post: 11-22-2006, 09:12 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