update all records

M

Mark Kubicki

this ought to be easy...

i want to update(?) 1 field in all of the records of a table that meet a
criteria

ex:
table = Notes, with fields ID, and print
for each record in table [Notes] where [ID] = variable, print = "true"

thanks in advance,
mark
 
R

Rick Brandt

Mark said:
this ought to be easy...

i want to update(?) 1 field in all of the records of a table that
meet a criteria

ex:
table = Notes, with fields ID, and print
for each record in table [Notes] where [ID] = variable, print =
"true"

Dim sql as String
sql = "UPDATE Notes " & _
"SET print = 'true' " & _
"WHERE ID = " & variable

CurrentDB.Execute sql, dbFailOnError

The above assumes ID is a numeric field and that print is a text field. If
print is a Yes/No field then use...

Dim sql as String
sql = "UPDATE Notes " & _
"SET print = -1 " & _
"WHERE ID = " & variable

CurrentDB.Execute sql, dbFailOnError
 
D

Dirk Goldgar

"Mark Kubicki" wrote in message
this ought to be easy...

i want to update(?) 1 field in all of the records of a table that meet a
criteria

ex:
table = Notes, with fields ID, and print
for each record in table [Notes] where [ID] = variable, print = "true"


Is this something you want to do in code? If so, you could use something
like this:

CurrentDb.Execute _
"UPDATE Notes SET Print = True WHERE ID = " & YourIDVariable, _
dbFailOnError

That's assuming (a) that your ID field is numeric, not text, and (b) that
Print is a yes/no field and you want to set it to the boolean value True,
not the text value "true". If I'm wrong in those assumptions, adjustments
have to be made.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top