Solved

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

Posted on 2015-02-05
4
185 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
[X]
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
4 Comments
 
LVL 50

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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…

749 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