Consulting

Results 1 to 4 of 4

Thread: Copy records with new date in the same table

  1. #1
    VBAX Regular
    Joined
    Jun 2007
    Posts
    67
    Location

    Copy records with new date in the same table

    I want to copy all records (preserving the old ones) from a certain date (a combination of month and year) with a new date.

    Here's what i've worked out.
    INSERT INTO TABLE ( Field1, Field2,Field3, Month, Year)
    SELECT TABLE.Field1, TABLE.Field2, TABLE.Field3 FROM TABLE
    WHERE (((TABLE.Month)=[OldMonth]) AND ((TABLE.Year)=[OldYear]));
    But obviously I'm not feeding in the new month values.
    David Delcor


  2. #2
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    Are you saying that you want to update all records with a specified date with a new date? If so they you want to use the following Syntax:
    [VBA]UPDATE Table SET Table.FieldName = DesiredResult[/VBA]

    You can add in WHERE clauses as usual, along with anything else you may need.
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


  3. #3
    VBAX Newbie
    Joined
    Oct 2008
    Posts
    1
    Location
    You are very close. I would use following command:
    INSERT INTO TABLE ( Field1, Field2,Field3, Month, Year)
    SELECT TABLE.Field1, TABLE.Field2, TABLE.Field3, NewMonth, Newyear
    FROM TABLE WHERE (((TABLE.Month)=[OldMonth]) AND ((TABLE.Year)=[OldYear]));
    where NewMonth and NewYear are new date

  4. #4
    VBAX Regular
    Joined
    Jun 2007
    Posts
    67
    Location
    Yeah! Wasn't so difficult, was it?

    Thanks dude!
    David Delcor


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •