Error trapping Null or zero-length Primary Keys (1 Viewer)

Alexandre

Registered User.
Local time
Today, 10:50
Joined
Feb 22, 2001
Messages
794
In order to replace Acess default message when a required field is left blank or filled whith a non allowed zero-length string, I usually de-activate the required and zero-lenghth properties in the backend table and replace them with equivalent validation rules and a custom message.

Not that I am very satisfied with this method but I could not figure out so far how to error_trap null or zero-length fields whatever action the user may undertake(ex: in a form+subform where the user leaves a required filed of the parent form blanks, what event would you use to error trap?)

Now, my method is not working anymore with PK for which "required" and "zero-length not allowed" properties are checked by Access before the field or table validation rule...

So what is the usual way to handle that pb?
 

A real begineer

Registered User.
Local time
Today, 04:50
Joined
Nov 4, 2000
Messages
74
I have been using a "if IsNull(txtT) then " on the lost focus event on the control to force the user into a loop, where required data must be entered. I think there is a more elegant solution but this seems to work okay.
 

Alexandre

Registered User.
Local time
Today, 10:50
Joined
Feb 22, 2001
Messages
794
Thank you. I ll try
 

Robert Dunstan

Mr Data
Local time
Today, 04:50
Joined
Jun 22, 2000
Messages
291
Just zooming in on the Required property of a field, you can trap this error by using error number 3314.

I usually place my error trapping code in the OnError event as this is triggered by the BeforeUpdate event. However you may need to place the error trapping code in your control's OnLostFocus event or in some other more purposeful event, then you need to use the OnError statement to direct you application to the error handling code.

HTH
Rob
 

Users who are viewing this thread

Top Bottom