Need to return an error

  • Thread starter Thread starter AZRedHat
  • Start date Start date
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]));
 
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
 
Back
Top