Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How replace default message when duplicate entry is made in continuous form

Posted on 2015-02-05
4
184 Views
Last Modified: 2015-02-05
I have a continuous form that is used for entering part orders.  The field that the user select a part from is a combobox.  The field in the orders table is set as Indexed (No Duplicates).

If the user selects a part that has already been selected in another record in the continuous form they get a canned error message that reads "The changes you requested to the table were not successful because they would create duplicate values in the index........" and so forth.

I want to replace that error message with my own message.  How can I do this?
0
Comment
Question by:SteveL13
4 Comments
 
LVL 49

Assisted Solution

by:Gustav Brock
Gustav Brock earned 167 total points
ID: 40591133
Use the BeforeUpdate or BeforeInsert event to check that the part doesn't exist.

    Cancel = Not IsNull(DLookup( ... ))

/gustav
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 166 total points
ID: 40591172
use the beforeupdate event of the combo

private sub combo_beforeupdate(cancel as integer)
if dcount("*","tableName", "fieldname='" & me.combo & ''")> 0 then
  msgbox "duplicate"
  cancel=true
end if
end sub
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 167 total points
ID: 40591292
<<
I want to replace that error message with my own message.  How can I do this?
>>

 Use the forms OnError event.   Any errors the form encounters will fire this event.   Two variables are passed in; the error that occurred (dataerr) and response.

 Response is what you set to tell Access what to do.   If set to acDataErrContinue, Access will ignore the error and skip displaying the message box.

 This allows you to put up your own message.

acDataErrDisplay is the default action that your seeing now.

Jim.
0
 

Author Closing Comment

by:SteveL13
ID: 40591720
All three very useful tips.  Thank you.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question