Update Query on Single Record

  • Thread starter Thread starter Michael
  • Start date Start date
M

Michael

How do i run an update query from a form to only affect
that single record?? Same for an append query??

I am using Access 2002.

Any help would be great!!

-Michael
 
Michael said:
How do i run an update query from a form to only affect
that single record?? Same for an append query??

You include a WHERE clause in the query that has that single Primary Key
value as criteria.

Examples: (Numeric PK field named [ID])

UPDATE SomeTable
SET SomeField = SomeValue
WHERE [ID] = SomeNumber

INSERT INTO TargetTable
SELECT SomeFields FROM SourceTable
WHERE SourceTable.[ID] = SomeNumber
 
I think you might have misunderstood me. What i want to
do is have it append whatever record I happen to be on at
the time to another table, but only that one record. So
this means that the primary key could be anything so I do
not want to hard code it in. Does this clarify the
issue?? Thanks for your help!

-Michael

-----Original Message-----
Michael said:
How do i run an update query from a form to only affect
that single record?? Same for an append query??

You include a WHERE clause in the query that has that single Primary Key
value as criteria.

Examples: (Numeric PK field named [ID])

UPDATE SomeTable
SET SomeField = SomeValue
WHERE [ID] = SomeNumber

INSERT INTO TargetTable
SELECT SomeFields FROM SourceTable
WHERE SourceTable.[ID] = SomeNumber


--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


.
 
Michael said:
I think you might have misunderstood me. What i want to
do is have it append whatever record I happen to be on at
the time to another table, but only that one record. So
this means that the primary key could be anything so I do
not want to hard code it in. Does this clarify the
issue?? Thanks for your help!

My same examples below still assuming the PK is named ID and is represented
in the Form's RecordSource or is present as a control on the form.

UPDATE SomeTable
SET SomeField = SomeValue
WHERE [ID] = Forms!YourFormName![ID]

INSERT INTO TargetTable
SELECT SomeFields FROM SourceTable
WHERE SourceTable.[ID] = Forms!YourFormName![ID]
 
Back
Top