[AccessD] How to Trap ?Insert Error? (Duplicate record) causedby Indexed Field (No Duplicates)

jwcolby jwcolby at colbyconsulting.com
Mon Feb 28 20:17:22 CST 2011


You can also get NoRecsAffected from the db.Execute

John W. Colby
www.ColbyConsulting.com

On 2/28/2011 9:03 PM, Brad Marks wrote:
> Stuart,
>
> Yes, thanks a million for the help.
>
> Here is what I learned tonight...
>
> By switching from
>
> “DoCmd.RunSQL SQL_String”
>
> to
>
> “CurrentDb.Execute SQL_String, dbFailOnError”
>
> I can trap Err.Number = 3022 (duplicate record)
>
>
>
> I really appreciate the help.  I was pulling my hair out as I thought that the “DoCmd.RunSQL SQL_String” method would allow me to see the 3022 error.
>
> Brad
>
>
>
>
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com on behalf of Stuart McLachlan
> Sent: Mon 2/28/2011 7:26 PM
> To: Access Developers discussion and problem solving
> Subject: Re: [AccessD] How to Trap ?Insert Error? (Duplicate record) causedby Indexed Field (No Duplicates)
>
> Hi Brad,
>
> I just answered this for you on Linked In.
>
> Use CurrentDB.Execute str_SQL ,dbFailOnError
> instead of DoCmd.RunSQL.
>
> Then look for Err.Number 3022 in your error trap.
>
>



More information about the AccessD mailing list