Results 1 to 13 of 13
  1. #1
    jlclark4 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Dec 2010
    Location
    North Carolina
    Posts
    155

    Criteria based on another field

    I have a append query that i am trying to get set up correctly.



    AcctNumber
    RecdDate
    FiledDate
    FinalDate

    I want Field 4 to be only those records that are Null or records that are less then RecdDate.

    How would I do this? I tried a basic < RecdDate but it did not work.

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    You are mixing apples and oranges! "I want Field 4 to be only those records that are Null or records that are less then RecdDate" - Field 4 (FinalDate?) is a field and not a record. Are you trying to populate it with something, or do you want to only append records with that criteria?

  3. #3
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Do you mean records that have a Null value in FinalDate
    OR
    Where the FinalDate is < RecdDate?

  4. #4
    jlclark4 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Dec 2010
    Location
    North Carolina
    Posts
    155
    Sorry, I know nothing about Append queries. Thus needing the help.

    I want to only append records with that criteria.

    Field 4 = FinalDate (I orginally had just Field 1-4 on the question, then changed to actual names)

    I am looking for:

    FinalDate = Null
    or
    FinalDate < RecdDate

    I was putting the criteria under the FinalDate field in the query.

  5. #5
    jlclark4 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Dec 2010
    Location
    North Carolina
    Posts
    155
    Am I looking at this the wrong way?

  6. #6
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    In your Criteriayou have a 'Between . . .' and 'Is Null' on the same Criteria Row [in different fields].
    That is saying "Between these two dates AND Is Null".
    Those two are contradicting each other - because they are on the same Criteria Row.

    Click View [top left] and 'SQL View' and you will see what your query actually 'says'.

  7. #7
    jlclark4 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Dec 2010
    Location
    North Carolina
    Posts
    155
    The Received date should be in between that date range.

    Like the receive date is 2/1/2012
    The Final Date is Null
    It should append to the table.
    B/c Final Date = Is Null

    Or
    The Receive date is 2/8/2012
    The Final Date is 2/1/2012
    It should append to the table
    B/c Received Date > Final Date

    Does that make sense?

  8. #8
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Can you please open your query in SQL View and paste the SQL statement in here for us to look at?

  9. #9
    jlclark4 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Dec 2010
    Location
    North Carolina
    Posts
    155
    This gives more detail on the actual table names and such. Let me know if this helps or makes things worse.
    This code is as is without the > then dtmClmFinDate that I attempted to do.

    Code:
    INSERT INTO [ZZ MasterList_ClaimsRecd] ( LMSAcctNo, UGCertNo, LenderLoanNo, LenderID, ClaimRecdDate, LenderName, ClaimFiledAmt, AcknowledgementDate, strCompNbr )
    SELECT dbo_tblAccount.dblAcctNbr, dbo_tblAccount.strCertNbr AS UGCertNo, dbo_tblAccount.strLenderLnNbr AS LenderLoanNo, dbo_tblAccount.strLenderID AS LenderID, dbo_tblAccount.dtmClmRecDate AS ClaimRecdDate, LenderList.LndrName AS LenderName, dbo_tblAccount.dblLenderFiledClmAmt AS ClaimFiledAmt, Date() AS AcknowledgementDate, dbo_tblAccount.strCompNbr
    FROM dbo_tblAccount LEFT JOIN LenderList ON dbo_tblAccount.strLenderID = LenderList.LndrNo
    WHERE (((dbo_tblAccount.dtmClmRecDate) Between #1/1/2010# And Date()) AND ((dbo_tblAccount.dtmClmFinDate) Is Null));
    So, with these actual field names, I am looking for:

    dtmClmFinDate = Null
    or
    drmClmFinDate < dtmClmRecDate

    For the dtmClmRecDate range of 1/1/2010 - Today

  10. #10
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    What happens when you run this query?

  11. #11
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    When you run the Select . . . part of the query - do you get the results that you want?

  12. #12
    jlclark4 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Dec 2010
    Location
    North Carolina
    Posts
    155
    The query above DOES populate what it says. So it works. I need to adjust it to include:

    dtmClmFinDate = Null or drmClmFinDate < dtmClmRecDate

    For the dtmClmRecDate range of 1/1/2010 - Today

    I have never referenced another field in a query before so that's where I am having my problem.

  13. #13
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    I just ran a simple query and used two fields in the Table 'Test' to filter the records and it worked just fine.
    Code:
     
    SELECT [Test].ID, [Test].[Order], [Test].[Name], [Test].[Boxes], [Test].[DaysOnHold], [Test].[REASON]
    FROM Test
    WHERE [Test].[Boxes] >[Test].[DaysOnHold];
    Tell me if this is what you need in your WHERE clause:
    1. WHERE (((dbo_tblAccount.dtmClmRecDate) Between #1/1/2010# And Date()) AND ((dbo_tblAccount.dtmClmFinDate) Is Null))
    . . . you already have this in your query.
    AND
    2. dtmClmFinDate = Null or drmClmFinDate < dtmClmRecDate
    AND
    3. dtmClmRecDate range of 1/1/2010 - Today

    If it is, then try something like this for your WHERE clause:
    Code:
     
    WHERE (((dbo_tblAccount.dtmClmRecDate) Between #1/1/2010# And Date()) AND ((dbo_tblAccount.dtmClmFinDate) Is Null))
    AND ((dtmClmFinDate = Null) or (drmClmFinDate < dtmClmRecDate))
    AND (dtmClmRecDate > #1/1/2010#);
    Note: I ran the above logic in my test query and it works. What you'll have to evaluate is whether you want AND . . . or whether you want OR - between the three parts of the WHERE clause.

    Let me know if it works!!

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

Similar Threads

  1. data field in query twice based on criteria
    By sandyg in forum Queries
    Replies: 1
    Last Post: 09-29-2011, 07:47 AM
  2. Replies: 5
    Last Post: 03-06-2011, 10:38 AM
  3. Replies: 30
    Last Post: 03-01-2011, 10:05 AM
  4. Replies: 4
    Last Post: 01-19-2010, 05:36 AM
  5. query - criteria based on another row field value
    By techexpressinc in forum Queries
    Replies: 1
    Last Post: 05-29-2009, 04:17 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