Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / November 2006

Tip: Looking for answers? Try searching our database.

Validation Rule

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SG - 29 Nov 2006 18:23 GMT
I have setup a validation rule of Not "" but it still allows the form to be
saved even though the field has been left empty??

Any Suggestions?

Many Thanks

S
John Vinson - 29 Nov 2006 18:40 GMT
>I have setup a validation rule of Not "" but it still allows the form to be
>saved even though the field has been left empty??
[quoted text clipped - 4 lines]
>
>S

Set the field's Required property to true instead.

"" is a String value, a zero length string.

NULL is a *different* value, or better non-value. A field that is NULL
is undefined, empty, unspecified; "" is defined, non-empty, specified
- you know exactly what it is, it's a zero length string.

Setting a field as Required in a table will prohibit saving a record
where that field is NULL. Note that if you also set the Allow Zero
Length String property to Yes (it's No by default), you can have "" as
a valid, non-NULL value; this combination should be used with great
caution and only when needed, since it's very hard to tell a NULL from
a zero-length string!

                 John W. Vinson[MVP]
Jeff L - 29 Nov 2006 18:42 GMT
If a field is empty, it has a value of Null which is not the same thing
as "".

> I have setup a validation rule of Not "" but it still allows the form to be
> saved even though the field has been left empty??
[quoted text clipped - 4 lines]
>
> S
Marshall Barton - 29 Nov 2006 18:43 GMT
>I have setup a validation rule of Not "" but it still allows the form to be
>saved even though the field has been left empty??

Check the table field's Required property.  This prevents
Null values from being saved.  I think you want this set to
Yes.  This translates to the validation rule  Is Not Null.

Check the table field's AllowZeroLength property.  This
prevents empty string values from being saved.  It sounds
like you want this property set to No.  I think this
corresponds to a validation rule similar to  <> ""

Signature

Marsh
MVP [MS Access]

SG - 29 Nov 2006 20:30 GMT
Marshall,

I have checked the fields required porperty to yes and allow zero length
property to no but the problem I seem to have now is its not very user
friendly with regards to the message which is presented to the user when
they forget to complete the field eg The field 'tblcustomers.title' cannot
contain a null value because the required property for this field is set to
true, Enter a value in this field. The system then asks be to close the form
anyway and I select no and get an action failed dialogue message.

Does anyone have any suggestions?

>>I have setup a validation rule of Not "" but it still allows the form to
>>be
[quoted text clipped - 8 lines]
> like you want this property set to No.  I think this
> corresponds to a validation rule similar to  <> ""
Marshall Barton - 29 Nov 2006 21:56 GMT
You can trap those errors using the form's Error event:

Private Sub Form_Error(DataErr As Integer, Response As
Integer)
  Select Case DataErr
   Case 3314
       MsgBox "You must specify ..."
       Response = acDataErrContinue
   Case 3315
       MsgBox "You can not use an empty ..."
       Response = acDataErrContinue
   End Select  
End Sub

OTOH, if that's not the approach you want to take, you can
allways use the validation rules I posted earlier.  I
wouldn't bother with the zero length string rule because a
user would have to type "" to enter a ZLS.
Signature

Marsh
MVP [MS Access]

>I have checked the fields required porperty to yes and allow zero length
>property to no but the problem I seem to have now is its not very user
[quoted text clipped - 18 lines]
>> like you want this property set to No.  I think this
>> corresponds to a validation rule similar to  <> ""
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.