Solved

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

Posted on 2015-02-05
4
181 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 119

Assisted Solution

by:Rey Obrero
Rey Obrero 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now