I have an update query which I want to run when a record is given focus in a
form.
But I do not know how to reference this either in the event property or the
query itself so that the query does not update all the records in the target
table.
Can anyone else?
Not much to go on here.
What is the name of the field you wish to update?
What is it's datatype?
Where do you get the value you wish to update the field to?
You don't need a separate query.
Each record should have it's own Prime Key unique record number.
Let's assume it's named [RecordID], and that it is a Number datatype.
Code an event on the form (perhaps the form's current event if you
wish to do this as you navigate to each record):
Dim strSQL as String
strSQL = "Update MyTable Set MyTable.[FieldName] = SomeValue Where
MyTable.[RecordID] = " & Me.[RecordID]
CurrentDb.Execute strSQL, dbFailOnError
If you get an error that Access can't find Execute, make sure you have
a reference set to the Microsoft DAO 3.6 Object Library.
Open any VBA code window. Click on Tools + References.
If you don't see the DAO library checked up near the top of the list,
navigate down the list until you find it. Place a check in it's check
box. Close the list and save.
You'll have to adapt the above syntax to fields of different
datatypes.