Results 1 to 4 of 4

Thread: Apped 0 rows

  1. #1
    Join Date
    Feb 2005
    Posts
    2

    Post Unanswered: Apped 0 rows

    I'm doing a side project, a video rentals shop, and can't get this query to work:
    Code:
    INSERT INTO tbl_Rental ( Rental_ID, Customer_ID, Copy_ID, Rental_DateOut, Rental_Period, Rental_Price )
    SELECT tbl_Rental.Rental_ID, tbl_Rental.Customer_ID, tbl_Rental.Copy_ID, tbl_Rental.Rental_DateOut, tbl_Rental.Rental_Period, tbl_Rental.Rental_Price
    FROM tbl_Rental
    WHERE (((tbl_Rental.Customer_ID)=[Forms]![frm_Confirm_Rental]![txtCustomerID]) AND ((tbl_Rental.Copy_ID)=[Forms]![frm_Confirm_Rental]![Copy_ID]) AND ((tbl_Rental.Rental_DateOut)=Date()) AND ((tbl_Rental.Rental_Period)=[Forms]![frm_Confirm_Rental]![txtRentalPeriod]) AND ((tbl_Rental.Rental_Price)=[Forms]![frm_Confirm_Rental]![txtRentalPeriod]));
    Rental_ID is a autonumber, Date is worked out on the fly, but the rest of the values come from a Form. Whenever I run the query, from the form, or on it's own, it always says 'You are about to append 0 rows' and of course, the data doesn't get inserted into the table.

    Could anyone give me some pointers here?
    Thanks
    Matt

  2. #2
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    It looks to me like you are trying to insert a new record into a table, by pulling the same record from the table. Since you are adding a new record, of course the record doesn't exist in tblRental.

    Is your form bound or unbound to tblRental?
    Inspiration Through Fermentation

  3. #3
    Join Date
    Feb 2005
    Posts
    2
    It's bound to a query that is performed to find a DVD/VHS. Not all values in the form come from the query though, a couple come from the registry via VBA.

  4. #4
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    For simplicities sake, let's shorten your query to:

    INSERT INTO tbl_Rental ( Rental_ID)
    SELECT tbl_Rental.Rental_ID
    FROM tbl_Rental
    WHERE (((tbl_Rental.Customer_ID)=[Forms]![frm_Confirm_Rental]!txtCustomerID])

    That looks to me like you are just going to insert a duplicate record into your table. If you are in the process of adding a NEW customer, that customerID would not yet exist in tbl_Rental, so the query would append 0 records. If you had multiple rental_id's for the same customer_id, you would append multiple records.
    Inspiration Through Fermentation

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •