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

    Append or Update Query Solution


    I am looking for a solution for the following problem.

    I have 10,000+ records that need updated each month transitionally ie:

    ID Date Cost
    2 1/1/14 15000
    2 2/1/14 16500
    2 3/1/14 12000
    3 1/1/14 100
    3 2/1/14 100
    3 3/1/14 100

    Is there a way to update a table monthly so that instead of typing the month in for each record it will add a new line for the new month each time the query is run?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,942
    What does 'transitionally' mean?

    Essentially anything can be done with enough code. However, I don't really understand what you want. You want to edit or create records? With what data from where?
    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
    Sorry about my typo i mean Transactionally, for each ID I want to add a record with the new month

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,942
    Maybe an INSERT SELECT will work for you. Do you have a master table of the IDs - where ID is a unique identifier?

    INSERT INTO tablename(ID, [Date]) SELECT ID, Date() AS NewDate FROM IDtable


    BTW, Date is a reserved word. Should not use reserved words as names.
    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 do have a Master table with ID being the unique identifier.

  6. #6
    zbaker is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Posts
    18
    How do I go about doing that, my guess is SQL?

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,942
    Use the query builder SQL view to type an SQL statement. Then switch to Design View.

    If you want some date other than today, say the 1st:

    INSERT INTO tablename(ID, [Date]) SELECT ID, DateSerial(Year(Date()), Month(Date()), 1) AS NewDate FROM IDtable

    In VBA procedcure:

    CurrentDb.Execute "INSERT INTO tablename(ID, [Date]) SELECT ID, DateSerial(Year(Date()), Month(Date()), 1) AS NewDate FROM IDtable"
    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.

  8. #8
    zbaker is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Posts
    18
    If i just wanted it to say Month and Year would it be the following?
    INSERT INTO tablename(ID, [Date]) SELECT ID, DateSerial(Year(), Month()) AS NewDate FROM IDtable

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,942
    Can't have just month and year in a Date/Time type field. Also, the DateSerial arguments are not optional.
    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.

  10. #10
    zbaker is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Posts
    18
    Thanks for your help!

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

Similar Threads

  1. Update/Append Query
    By joannakf in forum Queries
    Replies: 5
    Last Post: 05-21-2012, 04:02 PM
  2. Replies: 3
    Last Post: 03-11-2012, 03:35 PM
  3. Update or Append Query
    By Ran in forum Access
    Replies: 8
    Last Post: 01-06-2012, 12:15 PM
  4. An integrated Append + Update query ?!
    By cement in forum Queries
    Replies: 3
    Last Post: 12-31-2010, 11:01 AM
  5. Append/Update Query -- Need Help!
    By su-san in forum Queries
    Replies: 12
    Last Post: 11-08-2010, 12:52 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