Results 1 to 2 of 2
  1. #1
    GoVols02 is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2010
    Posts
    3

    SQL Subquery on Previous Record

    I have the following setup

    Table - tblDailyInformation
    Field - DateSold - data type is Date/Time - Primary Key
    Field - Register 1 Sales - data type is Currency

    Here is some sample data....
    DateSold Register 1 Sales
    12/18/2009 1173.24
    12/19/20093 1081.95
    12/20/2009 1019.33
    12/21/2009 818.65
    12/22/2009 874.03

    This is a parameter query and the user enters DateSold as [Date Sold:]. I am trying to retrieve Register1Sales for the date that the user enters and also Register1Sales AS OldSales from the previous record. So, if the user entered "12/20/2009", I need to retrieve the following
    Register 1 Sales OldSales
    1019.33 1081.95

    My SQL is below…

    select [register 1 sales]
    from tblDailyInformation
    where [Date Sold]=[Date Sold:]
    (SELECT [register 1 sales] as OldSales
    FROM tblDailyInformation


    WHERE [Date Sold:]=dateadd("d",+1,[Date Sold]))
    When I run this I get the following error message
    “Undefined Function ‘[Date Sold:]’ in expression
    What am I doing wrong?

  2. #2
    z1efuller1 is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2009
    Posts
    9
    Could be wrong, but I do not believe that Access wil let you do subqueries.

    You can create a cascading combo box on a form view that will display this information for you after selecting the date however.

    This link will show you how to set one up. (Thanks Rural Guy)

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

Similar Threads

  1. Replies: 2
    Last Post: 11-04-2009, 09:45 PM
  2. Populate date from previous record
    By Lianes in forum Access
    Replies: 3
    Last Post: 09-19-2009, 03:42 PM
  3. Add data from previous record if blank
    By mbc321 in forum Queries
    Replies: 1
    Last Post: 08-08-2009, 05:15 PM
  4. Problem with subquery
    By bakerdenn in forum Queries
    Replies: 1
    Last Post: 04-24-2009, 10:37 PM
  5. using value from previous record
    By dollars in forum Queries
    Replies: 0
    Last Post: 12-10-2008, 03:30 PM

Tags for this Thread

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