Results 1 to 7 of 7
  1. #1
    littlewing is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2012
    Posts
    4

    Using Current Date in a Query


    For a school project, I basically need to make a query that lists dates within a month of the current date. The problem is, the dates are laid out as such: PK field, Order FK, Payment 1, Payment 2, ... , Payment 12. I need a query that will, when ran, return to me a list of the orders and payments within one month of the date. Using Month([Schedule].[Payment 1])=Month(Now()) as a criteria returns to me the entire record, not the individual dates. Is there any way to do what I want?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Don't understand. Why would you not want the entire record? Which individual dates do you mean? Show sample source data and sample output.

    Using month as criteria only returns records dated from the first of the month. Is that what you want?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    littlewing is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2012
    Posts
    4
    Quote Originally Posted by June7 View Post
    Don't understand. Why would you not want the entire record? Which individual dates do you mean? Show sample source data and sample output.

    Using month as criteria only returns records dated from the first of the month. Is that what you want?
    More specifically: Is there any way to merge multiple fields from a form into one column of a query while still maintaining data integrity with other tables? I have been able to merge all of the dates into one column using UNION, but can not add that column to a query with the customer name and phone number that correspond to each date. It instead shows every customer name with its corresponding phone number, but rather than being followed by just the dates that correspond with the names, each name/phone number is followed by every date.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    I would have to examine your data and queries if you want to provide project for analysis. Follow instructions at bottom of my post.

    A UNION basically rearranges data to a normalized structure. Possibly data should be structured this way to begin with.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    littlewing is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2012
    Posts
    4
    Prototype2.accdb.zip
    Quote Originally Posted by June7 View Post
    I would have to examine your data and queries if you want to provide project for analysis. Follow instructions at bottom of my post.

    A UNION basically rearranges data to a normalized structure. Possibly data should be structured this way to begin with.
    Basically, I need to have a report that will show me which payment dates are within three weeks of the current date, along with the customer that the dates apply to and phone numbers.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Try:

    Union query: CustomerPayDates
    SELECT [Order FK], "P01" As PayID, [Payment 1] As PayDate FROM Schedule
    UNION SELECT [Order FK], "P02", [Payment 2] FROM Schedule
    ...
    UNION SELECT [Order FK], "P12", [Payment 12] FROM Schedule;

    Then:
    SELECT Customers.*, CustomerPayDates.PayID, CustomerPayDates.PayDate
    FROM Customers INNER JOIN CustomerPayDates ON Customers.[Customer PK] = CustomerPayDates.[Order FK]
    WHERE (((CustomerPayDates.PayDate) Between Date() And Date()+21));
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    littlewing is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2012
    Posts
    4
    Quote Originally Posted by June7 View Post
    Try:

    Union query: CustomerPayDates
    SELECT [Order FK], "P01" As PayID, [Payment 1] As PayDate FROM Schedule
    UNION SELECT [Order FK], "P02", [Payment 2] FROM Schedule
    ...
    UNION SELECT [Order FK], "P12", [Payment 12] FROM Schedule;

    Then:
    SELECT Customers.*, CustomerPayDates.PayID, CustomerPayDates.PayDate
    FROM Customers INNER JOIN CustomerPayDates ON Customers.[Customer PK] = CustomerPayDates.[Order FK]
    WHERE (((CustomerPayDates.PayDate) Between Date() And Date()+21));
    That works perfectly! Thanks a lot

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

Similar Threads

  1. Replies: 5
    Last Post: 04-03-2012, 07:24 AM
  2. Replies: 1
    Last Post: 12-07-2011, 01:02 PM
  3. Replies: 2
    Last Post: 10-08-2011, 06:33 PM
  4. query criteria for current date
    By Paul-NY in forum Queries
    Replies: 5
    Last Post: 07-05-2011, 02:21 PM
  5. Replies: 9
    Last Post: 03-19-2010, 10:37 AM

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