473,414 Members | 1,947 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Supress Default Primary Key Message

is there a way to suppress the standard Access warning when a user
attempts to add a record that violates a unique index/primary key? I
would prefer to have a custom message box...

Thanks!
Nov 13 '05 #1
4 2100
On Wed, 3 Aug 2005 20:57:02 -0400, David Boothe <no*@onyourlife.net>
wrote:

Depends on exactly what you're trying to do, but likely you could
write some code in the Form_OnError event.

-Tom.

is there a way to suppress the standard Access warning when a user
attempts to add a record that violates a unique index/primary key? I
would prefer to have a custom message box...

Thanks!


Nov 13 '05 #2
Br
David Boothe <no*@onyourlife.net> wrote:
is there a way to suppress the standard Access warning when a user
attempts to add a record that violates a unique index/primary key? I
would prefer to have a custom message box...

Thanks!


First find out what the error code is (I can't remember it off hand)

Private Sub Form_Error(DataErr As Integer, Response As Integer)
MsgBox "Error number: " & DataErr
Response = acDataErrDisplay
End Sub

Then change the code to the following and insert the error number you
need.

Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 1234 Then 'change the code to the one you need
MsgBox "You need a primary key!"
Response = acDataErrContinue 'don't display the default access error
Else
Response = acDataErrDisplay 'diaply the default Access error
End If
End Sub

--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 13 '05 #3
On Wed, 3 Aug 2005 20:57:02 -0400, David Boothe <no*@onyourlife.net>
wrote:

Depends on exactly what you're trying to do, but likely you could
write some code in the Form_OnError event.

-Tom.

is there a way to suppress the standard Access warning when a user
attempts to add a record that violates a unique index/primary key? I
would prefer to have a custom message box...

Thanks!


Nov 13 '05 #4
Br
David Boothe <no*@onyourlife.net> wrote:
is there a way to suppress the standard Access warning when a user
attempts to add a record that violates a unique index/primary key? I
would prefer to have a custom message box...

Thanks!


First find out what the error code is (I can't remember it off hand)

Private Sub Form_Error(DataErr As Integer, Response As Integer)
MsgBox "Error number: " & DataErr
Response = acDataErrDisplay
End Sub

Then change the code to the following and insert the error number you
need.

Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 1234 Then 'change the code to the one you need
MsgBox "You need a primary key!"
Response = acDataErrContinue 'don't display the default access error
Else
Response = acDataErrDisplay 'diaply the default Access error
End If
End Sub

--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: LRW | last post by:
I'm creating a simple reply form, and if a form item isn't answered I get an error: "Notice: Undefined index: rb_amntspent in c:\inetpub\wwwroot\mackinaw\survey.php on line 36" even if in the...
14
by: ford_desperado | last post by:
Why isn't ALLOW REVERSE SCANS the default? Why do we have to - drop PK - create an index - recreate PK What are the advantages of indexes that do not allow reverse scans?
3
by: Ian D | last post by:
Firstly apologies for the convoluted question. I found this problem whilst building a larger database. I've distilled it down to as small as possible and can send a 200k example to anyone who has...
5
by: DSmith | last post by:
Is it possible to make whatever is inputted the default value of a field until a different value is inputted? Thanks in advance!
0
by: David Boothe | last post by:
is there a way to suppress the standard Access warning when a user attempts to add a record that violates a unique index/primary key? I would prefer to have a custom message box... Thanks!
1
by: David | last post by:
I have a custom control that contains a class that Inherits the panel control. I am trying to catch a keydown event in this class and then supress it from the rest of the control as well as the...
6
by: dbuchanan | last post by:
Hello, Is this a bug? Is there some kind of work around? I want to add default values for a few columns in my datagridview I found the "DefaultValuesNeeded" event for the datagridview I...
8
by: Leon_Amirreza | last post by:
I have a column named "ID" and its type is "uniqueidentifier" in SQL Server 2005 Express. this column is the primary key and its default value is "newid()" in SQL Server. I have generated a...
2
by: khani | last post by:
Hi i have following situation in cystal report in detail section i have a field say name.now i have five duplication record like this zahid zahid zahid zahid
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.