Consulting

Results 1 to 4 of 4

Thread: update table from <date> to <date> using VBA

  1. #1
    VBAX Regular
    Joined
    Jun 2004
    Posts
    28
    Location

    update table from <date> to <date> using VBA

    Dear Friends,

    I want to write a piece of code (VBA) that updates the values of a table that are located between the dateA and dateB.

    To update the whole table I use the following:

    LFactor = 3
    LUpdate = "update [plhresTable]"
    LUpdate = LUpdate & " set [PraxiOgkos] = [PraxiOgkos]*" & LFactor
    db.Execute LUpdate, dbFailOnError

    How can I apply the above action between dates dateA and dateB?

    Thanks in advance,
    G.

  2. #2
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Why do you want to use VBA?

    Can't you just use an update query?

    To update between dates you will have to add a WHERE clause to your SQL statement.

  3. #3
    VBAX Regular GP George's Avatar
    Joined
    Jul 2004
    Location
    Puget Sound, WA
    Posts
    26
    Location
    You can add the "Where" clause to your code

    LFactor = 3
    LUpdate = "update [plhresTable]"
    LUpdate = LUpdate & " set [PraxiOgkos] = [PraxiOgkos]*" & LFactor
    LUpdate = LUpdate & " Where [DatetoUpdate] Between dateA and dateB"
    db.Execute LUpdate, dbFailOnError
    "We're all in this together."
    -Red Green

  4. #4
    VBAX Regular
    Joined
    Jun 2004
    Posts
    28
    Location
    Thread is solved. Thank you!
    G.

Posting Permissions

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