Update record value= old value +1

Ammarhm

Beginner User
Local time
Today, 15:54
Joined
Jul 3, 2008
Messages
80
Hi guys
is there a simple way to update the value of a specific record in a table so that the new value is the old value +1?
let us say i have a table1 and i want to update the value of units where the Item column equals Cars
i can do this by:

Dim oldVal as Integer
Dim sqlString as String
oldVal= DLookup("Units", "Table1", "[Item]= Cars")
oldValue=oldValue+1
sqlString = "Update [Table1] Set [Units]= '" & oldVal & "' Where [Item]= Cars "
DoCmd.SetWarnings False
DoCmd.RunSQL sqlString
DoCmd.SetWarnings True


The whole thing feels however awckward, there has to be an easier way to do that ??
ANy suggestions?
 
Try

CurrentDb.Execute "Update [Table1] Set [Units] = [Units] + 1 Where [Item]= 'Cars'"
 
thanks man¨
really appreciate your answer
 
If you caddied for me, you'd know how bad I really am!
 

Users who are viewing this thread

Back
Top Bottom