Solved

change message -you cannot go to specific record

Posted on 2011-03-10
3
297 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
Comment Utility
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
Comment Utility
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 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

772 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

11 Experts available now in Live!

Get 1:1 Help Now