473,404 Members | 2,179 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,404 software developers and data experts.

Change primary key error message ms access

Nathan H
104 100+
I get the standard message on a form when a new record is created without supplying a new or valid primary key. Where can I put the On Error code so it will override the generic "Primary Key Can Not Contain a Null Value" and replace it with more detailed instructions.
Dec 19 '07 #1
4 6354
puppydogbuddy
1,923 Expert 1GB
I get the standard message on a form when a new record is created without supplying a new or valid primary key. Where can I put the On Error code so it will override the generic "Primary Key Can Not Contain a Null Value" and replace it with more detailed instructions.
Hi Nathan,
If it is a trapable error, you can intercept it and display a custom message using the Form_Error event. See this link for a step by step:

http://www.databasedev.co.uk/custom-error-message.html
Dec 19 '07 #2
Nathan H
104 100+
Hi Nathan,
If it is a trapable error, you can intercept it and display a custom message using the Form_Error event. See this link for a step by step:

http://www.databasedev.co.uk/custom-error-message.html
Hi pdb,

Yeah, the form error property works, but then is instantly followed by the standard "Primary Key/Null Value" message box.

I need to find a way to suppress that message, and then the form error property will due fine...

Nathan
Dec 19 '07 #3
puppydogbuddy
1,923 Expert 1GB
Hi pdb,

Yeah, the form error property works, but then is instantly followed by the standard "Primary Key/Null Value" message box.

I need to find a way to suppress that message, and then the form error property will due fine...

Nathan
Nathan,
If the error is a trapable error, issuing the Response = acDataErrContinue after you have trapped it and displayed your custom message is supposed to suppress the standard message. You followed the instructions in the link? And it is not working?? Can you post your code?
Expand|Select|Wrap|Line Numbers
  1. If DataErr = conErrRequiredData Then
  2.         MsgBox ("Please ensure that you enter a First Name and Last Name")
  3.         Response = acDataErrContinue
  4.     Else
  5.         'Display a standard error message
  6.         Response = acdatadisplay
  7.     End If
Dec 19 '07 #4
Nathan H
104 100+
Got it now. for some reason I was getting an Error 3023 on the trap....after compacting the db I then got the correct Error 3058. Code works fine now:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Error(DataErr As Integer, Response As Integer)
  2.  
  3. 'If an error occurs because of missing data in a required field
  4. 'display our own custom error message
  5.  
  6.     Const conErrRequiredData = 3058
  7.  
  8.     If DataErr = conErrRequiredData Then
  9.         MsgBox ("Please add an author id to each new author entry")
  10.         Response = acDataErrContinue
  11.     Else
  12.         'Display a standard error message
  13.         Response = acdatadisplay
  14.     End If
  15. End Sub
Dec 19 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: Philip Yale | last post by:
I'm probably going to get shot down with thousands of reasons for this, but I've never really heard or read a convincing explanation, so here goes ... Clustered indexes are more efficient at...
9
by: Neil | last post by:
I've been discussing here a SQL 7 view which scrolls slowly when linked to an Access 2000 MDB. After trying various things, I've distilled it down to the following: when the linked view has a...
5
by: Geoff Cayzer | last post by:
At http://www.blueclaw-db.com/tips_tricks.htm I came across a section which is included below and was hoping for some comment on the article. -------------- Almost never use this auto-number...
14
by: Abhi | last post by:
FYI: This message is for the benefit of MS Access Community. I found that this prblem has been encounterd by many but there is hardly any place where a complete solution is posted. So I thought...
5
by: Markus Stehle | last post by:
Hi all! I have asp.net web application that uses static impersonation. Is it possible to change the impersonated user during runtime? Within some parts of my application I would like to...
8
by: Paul Hunter | last post by:
I am new to databases and thus to Access. I have a situation where I am trying to figure out how to key some tables I am working with. Consider that I have a database of my own records which are...
6
by: ravichoudhari | last post by:
i came accross requirement of multiple foreign keys in a table referencing the same primary key another table. i created the table relations using the relations editor in access. even though i...
2
by: Khundeen | last post by:
Hi, I am trying to modify the primary key of a table. We need to add new field and make it part of the Primary key of the table. I thought I can use this SQL Statement. ALTER TABLE...
8
by: Simon | last post by:
Dear reader, The syntax for the VBA code to change the RowSource of a Form is: Forms!FormName..RowSource = "TableOrQueryName"
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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...

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.