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

    Select query question

    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

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    so what are you saying in this thread? that you want all records from last month? as in, from September of this year? if that is so, you can use criteria like this:
    Code:
    WHERE 
    
    format(DATEFIELD, "mm/yyyy") = 
    
    format(dateadd("m", -1, date()), "mm/yyyy")

  3. #3
    CoachBarker is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    17
    If this isNovember, when the form populates I want to show Octobers records for transactions, so if any editing needs to take palce before Novembers transactions are added they can be. That is why I thought using PaymentMadeDate Descending would return the previous months record.

    I got it to work without any date field issues. Thanks
    Last edited by CoachBarker; 11-01-2010 at 05:51 AM. Reason: resolved

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

Similar Threads

  1. Replies: 2
    Last Post: 03-23-2012, 09:20 AM
  2. select sum query
    By sparkles in forum Queries
    Replies: 1
    Last Post: 10-22-2010, 07:29 PM
  3. Cross Tab on Select Query
    By gazzieh in forum Queries
    Replies: 1
    Last Post: 02-04-2010, 12:07 PM
  4. VBA Script to run select query
    By pushpm in forum Programming
    Replies: 2
    Last Post: 05-06-2009, 08:36 AM
  5. very difficult (for me!) SELECT query
    By igorbaldacci in forum Queries
    Replies: 1
    Last Post: 12-02-2008, 03:30 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