Need to return an error

A

AZRedHat

I need this query to return an error if the second number typed in does not
exist in the table...

UPDATE [Table, main inventory part data] SET [Table, main inventory part
data].[# On Hand] = [# On Hand]+[Enter Number Parts Received]
WHERE ((([Table, main inventory part data].NSN) Like [Enter NSN to Update]));
 
M

Michel Walsh

Queries do not really return 'errors'... but can fail to make the update. In
fact, if there is a problem with the query, it is your VBA code or the
Form_Error event which *may* be able to trap the 'error'.

To fail the update, you can make something like:


UPDATE tableA SET ... WHERE ... AND EXISTS(SELECT * FROM tableA WHERE
member=parameter)



indeed, if there is NO member = parameter, the condition will be false for
every record and NONE of them will get updated.




Vanderghast, Access MVP
 

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