PDA

View Full Version : update table from <date> to <date> using VBA



banavas
03-17-2005, 01:30 AM
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.

Norie
03-17-2005, 06:29 AM
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.

GP George
03-21-2005, 04:20 PM
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

banavas
03-22-2005, 12:23 AM
Thread is solved. Thank you!
G.