I run a query in Visual Studio vb.net 2005 to return a dataset of all current customers from my DB. The WHERE clause is where no ending date has been set yet. I ORDER the query by PaymentMadeDate Descending, thinking it would return last months records for editing or adding a new record. But it returns records from 1/1/2010. Any suggestions?
Code:
SELECT tblRentalShedCustomer.RentalShedCustomerID, tblRentalShedCustomer.RentalID, tblRentalShedCustomer.StorageShedID, tblRentalShedCustomer.CustomerID, tblCustomers.FirstName, tblCustomers.MiddleInitial, tblCustomers.LastName, tblCustomers.Address, tblCityZip.City, tblCustomers.ZipCode, tblCustomers.State, tblCustomers.HomePhoneNumber, tblCustomers.CellPhoneNumber, tblCustomers.WorkPhoneNumber, tblCustomers.AltPhoneNumber, tblCustomers.Active, tblRentalShedCustomer.BeginningDate, tblRentalShedCustomer.EndingDate, tblStorageUnits.BuildingNumber, tblShedSize.ShedSize, tblStorageUnits.Available, tblRentals.PaymentMadeDate, tblRentals.PaymentBalanceDue, tblPaymentType.PaymentType, tblRentals.CheckNumber, tblCreditCardType.CreditCardName, tblRentals.CreditCardNumber, tblRentals.MoneyOrderNumber, tblRentals.LateCharges, tblRentalRate.RentalRate
FROM (tblShedSize INNER JOIN tblStorageUnits ON tblShedSize.ShedSizeID = tblStorageUnits.StorageUnitSizeID) INNER JOIN ((tblRentalRate INNER JOIN (tblPaymentType INNER JOIN (tblCreditCardType RIGHT JOIN tblRentals ON tblCreditCardType.CreditCardNameID = tblRentals.CreditCardNameID) ON tblPaymentType.PaymentTypeID = tblRentals.PaymentTypeID) ON tblRentalRate.RentalRateID = tblRentals.RentalRateID) INNER JOIN ((tblCityZip INNER JOIN tblCustomers ON tblCityZip.CityZipID = tblCustomers.CityID) INNER JOIN tblRentalShedCustomer ON tblCustomers.CustomerID = tblRentalShedCustomer.CustomerID) ON tblRentals.RentalID = tblRentalShedCustomer.RentalID) ON tblStorageUnits.StorageShedID = tblRentalShedCustomer.StorageShedID
WHERE (((tblRentalShedCustomer.EndingDate) Is Null))
ORDER BY tblRentals.PaymentMadeDate DESC;
Query Design View:
Attachment 2144