Results 1 to 6 of 6
  1. #1
    zbaker is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Posts
    18

    Update to SQL statement

    I have the following append query that each month add a new line to my records if it meets the criteria. I need to add to the criteria but i am not sure what to add. Currently it add a new line if the Contract Status is Active, I now need to to add a new line if there is no date for that record. So "WHERE (((FINANCEACCRUALSPREADSHEET.[Contract Status])="Active") AND [Accrual Month] Is Empty)"

    INSERT INTO AccrualUpdateTable ( AccrualRefID, [Accrual Month] )


    SELECT tblMASTERDeviceTable.AccrualRefID, DateSerial(Year(Date()),Month(Date()),1) AS NewDate
    FROM tblMASTERDeviceTable INNER JOIN FINANCEACCRUALSPREADSHEET ON tblMASTERDeviceTable.AccrualRefID = FINANCEACCRUALSPREADSHEET.AccrualRefID
    WHERE (((FINANCEACCRUALSPREADSHEET.[Contract Status])="Active");

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    If there is no date in AccrualUpdateTable?

    Try:

    [Accrual Month] Is Null

    or

    IsNull([Accrual Month])
    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
    zbaker is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Posts
    18
    If a new record was added then there is no date for that record for the month it was added unless done manually. The suggestions listed above did not apply the IS Null criteria, it appended to all records.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Sorry, my error, filter criteria on destination table fields is meaningless for an INSERT action, I was thinking UPDATE. Not really understanding the issue. What do you mean by 'if a new record was added then there is no date'? How can there be no date when the INSERT action just added records with date value?
    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
    zbaker is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Posts
    18
    I am using a parent child relationship question. Parent is the Device record, Child is the month record. The append query is used to add a new month to the device record. When a new device record is added a date is not assigned to the new device. I was hoping to add criteria to the append query to say that when a new device is added then append a month record with that device record.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Adding records to two tables?
    That would be 2 separate SQL actions.
    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.

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

Similar Threads

  1. Update statement
    By reysy28 in forum Access
    Replies: 4
    Last Post: 12-11-2014, 12:12 PM
  2. Help on SQL Statement for Update Query
    By KCC47 in forum Queries
    Replies: 4
    Last Post: 12-31-2013, 07:02 AM
  3. UPDATE TO IIF Statement
    By anilytics in forum Queries
    Replies: 5
    Last Post: 03-09-2012, 03:45 AM
  4. SQL Update statement help
    By kalltim in forum Access
    Replies: 6
    Last Post: 01-18-2012, 07:30 AM
  5. Replies: 2
    Last Post: 07-20-2011, 02:01 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