?
Solved

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

Posted on 2015-02-05
4
Medium Priority
?
187 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 51

Assisted Solution

by:Gustav Brock
Gustav Brock earned 668 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 664 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 58

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 668 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

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 …
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

752 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