Solved

change message -you cannot go to specific record

Posted on 2011-03-10
3
308 Views
Last Modified: 2012-05-11
Hello ,
i have a serial number field indexed as unique field-
if someone tries to enter duplicate serial number in a access form- a message displays- you cannot go to specific record-
is there anyway to change words in message to- serial number already exists?
thank you
0
Comment
Question by:davetough
3 Comments
 
LVL 19

Expert Comment

by:MINDSUPERB
ID: 35098922
Dave,

Is there any existing code that display the "you cannot go to specific record"? If there is, you may post it here, we just need to tweak it.

If there's none, you may use the code below:

If Dcount("SerialNumber","YourTable","[SerialNumber]='" & Nz(Me.SerialNumber,0) & "'")>1 Then
MsgBox "Serial number already exist."


Sincerely,
Ed
0
 

Author Comment

by:davetough
ID: 35099011
if you open database- open form button and then-
where you add record-
if you try to add a duplicate- it will give you message
thank you
EXample.mdb
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 35099300
you have to test  using  >0 to check if a serial number already exists, and use the beforeupdate event of the field

private sub serialNumber_beforeupdate(cancel as integer)
If Dcount("SerialNumber","YourTable","[SerialNumber]='" & Nz(Me.SerialNumber,0) & "'")> 0 Then
MsgBox "Serial number already exist."
cancel=true
end if

end sub

0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

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.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

730 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