Catching error on insert statement



I have a piece of code that queries an existing table to retrieve the last
number used, adds one to that number to generate the next number and inserts
it as the key value for a new record. I store this number and use it
throughtout the rest of the transactions on the form. Obviously the flaw in
that procedure is that someone else could grab the same number and use it
before the record saves, in which case I should get an insert error. I would
like to be able to catch that error and go back to the start. How do I do
that?
Thanks
.



Relevant Pages

  • Re: White Paper on How MSAccess interacts with SQL Server Back End?
    ... this newsgroup is about ADP and has nothing to do with ODBC linked ... For simple queries, Access will create a TSQL queries that will run on the ... these keys to retrieve the other fields from the tables by group of 10 rows. ... access path, hands it off os SQL2K, how SQL interprets it and then ...
    (microsoft.public.access.adp.sqlserver)
  • Re: Update Query, updating wrong table
    ... you don't union action queries. ... UPDATE tblTestUpdate as U INNER JOIN tblImportProducts as I ... and before I changed the SET it would grab the right ...
    (microsoft.public.access.queries)
  • Re: Another Database SQL Update question
    ... besides queries that set it. ... You have to grab the value *immediately* after ... a query or you might get a _Tally for some other action. ... could throw one for a loop due to an OKL triggering. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: hibernate question
    ... Daniel wrote: ... > queries to retrieve the data run fine, but every time I try to save ... The hibernate.show_sql config option is the easiest way to ...
    (comp.lang.java.programmer)
  • Re: First of and last of help!
    ... >the totals in queries (despite having done a search in this group and ... the physical order of records gets rearranged if you ... retrieve an arbitrary record's value, ... date/time field in the table and use a query searching for the maximum ...
    (microsoft.public.access.queries)