Results 1 to 4 of 4
  1. #1
    Baldeagle is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2011
    Location
    Northern Ireland
    Posts
    136

    Missing entries

    I am using a query to populate my Sub-Ledger table with instructions for the allocation of gifts received from donors who have standing instructions for the allocation of gifts which they make to our charity by bank standing order. Everything is working fine except where two credits are received from a single donor in the same month. The result is that in respect of the second credits no entry is made in the Sub-Ledger table. Can you tell me what I have done wrong in my query? And how can I correct it? The earlier stage of the Macro puts all the month's credits into the Ledger table. I then want to make matching entries in the Sub-Ledger table for each of these entries which will contain usually 2 or 3 subdivisions of the gift.

    I'm not very familiar with the forum and don't know where to find the 'CODE tag' for posting my code. So I apologise in advance for simply copying the SQL for my query here -
    INSERT INTO [Sub-Ledger] ( [Ledger Number], [Send name?], [Paid?], Amount, Society, Instructions )
    SELECT Ledger.[Ledger Number], Yes AS [Send Name], No AS Paid, CCur([Amount]*[Amount (Percentage)]/100) AS Share, [Standing Instructions for Allocations].Mission, [Standing Instructions for Allocations].Instructions
    FROM [Standing Instructions for Allocations] INNER JOIN Ledger ON [Standing Instructions for Allocations].[Donor Number] = Ledger.[Donor Number]
    WHERE (((Ledger.[Date Paid])>=DateSerial(Year(Date()),Month(Date())-1,1) And (Ledger.[Date Paid])<>DateSerial(Year(Date()),Month(Date()),0)))


    ORDER BY Ledger.[Ledger Number];
    I look forward to any assistance you can give me. If you need any further clarification just let me know.

  2. #2
    Baldeagle is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2011
    Location
    Northern Ireland
    Posts
    136
    Quote Originally Posted by Baldeagle View Post
    WHERE (((Ledger.[Date Paid])>=DateSerial(Year(Date()),Month(Date())-1,1) And (Ledger.[Date Paid])<>DateSerial(Year(Date()),Month(Date()),0)))
    Actually the problem isn't as described in my first post!! I have discovered that the missing entries are gifts received on 31 October. Why does my query not select these gifts? Should it not select all gifts received in the previous month?

  3. #3
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    I think the issue is with your WHERE clause:
    Code:
    WHERE (((Ledger.[Date Paid])>=DateSerial(Year(Date()),Month(Date())-1,1) And (Ledger.[Date Paid])<>DateSerial(Year(Date()),Month(Date()),0)))
    
    Note that:
    DateSerial(Year(Date()),Month(Date()),0)
    returns the last day of the previous month, which would be October 31.

    So this part of the criteria is saying to exclude anything whose Date Paid is October 31.
    So, it sounds like it is "working as designed" (maybe not how it was intended!).

  4. #4
    Baldeagle is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2011
    Location
    Northern Ireland
    Posts
    136
    Quote Originally Posted by JoeM View Post
    I think the issue is with your WHERE clause:
    Code:
    WHERE (((Ledger.[Date Paid])>=DateSerial(Year(Date()),Month(Date())-1,1) And (Ledger.[Date Paid])<>DateSerial(Year(Date()),Month(Date()),0)))
    
    Note that:
    DateSerial(Year(Date()),Month(Date()),0)
    returns the last day of the previous month, which would be October 31.

    So this part of the criteria is saying to exclude anything whose Date Paid is October 31.
    So, it sounds like it is "working as designed" (maybe not how it was intended!).
    Thanks for the clarification. I have now changed "<>DateSerial........" to "<=DateSerial....." and that includes the gifts received on the last day of the month.

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

Similar Threads

  1. Duplicate Entries
    By brownk in forum Reports
    Replies: 3
    Last Post: 09-11-2012, 12:56 PM
  2. New Entries to a Combo box
    By whojstall11 in forum Forms
    Replies: 3
    Last Post: 07-10-2012, 04:10 PM
  3. Locking entries
    By jo15765 in forum Forms
    Replies: 11
    Last Post: 11-16-2010, 07:54 AM
  4. Multiple entries
    By Ziggy-R in forum Access
    Replies: 11
    Last Post: 10-03-2010, 07:42 PM
  5. Y and N entries
    By Drisconsult in forum Access
    Replies: 4
    Last Post: 08-10-2010, 02:16 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