A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Control Validation



 
 
Thread Tools Display Modes
  #1  
Old June 30th, 2006, 01:05 PM posted to microsoft.public.access.forms
Confused Slug
external usenet poster
 
Posts: 21
Default Control Validation

What is the best expression to use in the Validate property for a control to
test that some text (of unconstrained length) has been entered.
  #2  
Old June 30th, 2006, 01:54 PM posted to microsoft.public.access.forms
Allen Browne
external usenet poster
 
Posts: 11,706
Default Control Validation

Open the table in design view, and set the field's Required property to Yes.

If you prefer to use the Validation Rule of the field in the table:
Is Not Null

If you want to do it in a form, use the BeforeUpdate event of the form to
test it the control IsNull(). You cannot merely use the Validation Rule of
the control, since that is not triggered if nothing is entered.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Confused Slug" wrote in message
...
What is the best expression to use in the Validate property for a control
to
test that some text (of unconstrained length) has been entered.



  #3  
Old June 30th, 2006, 02:17 PM posted to microsoft.public.access.forms
Confused Slug
external usenet poster
 
Posts: 21
Default Control Validation

I am currently using the the following code in the beforeupdate event,

Private Sub DESCRIPTION_22_BeforeUpdate(Cancel As Integer)

If IsNull(DESCRIPTION_22) = True Then
MsgBox "Enter text"
Cancel = True

End If

End Sub

I have found that the validation does not take place until the field has had
a value in it. When a new record is created i find that you can tab out of
the control without entering any text. Only when text has been added and
deleted does the validation event occur.


"Allen Browne" wrote:

Open the table in design view, and set the field's Required property to Yes.

If you prefer to use the Validation Rule of the field in the table:
Is Not Null

If you want to do it in a form, use the BeforeUpdate event of the form to
test it the control IsNull(). You cannot merely use the Validation Rule of
the control, since that is not triggered if nothing is entered.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Confused Slug" wrote in message
...
What is the best expression to use in the Validate property for a control
to
test that some text (of unconstrained length) has been entered.




  #4  
Old June 30th, 2006, 03:49 PM posted to microsoft.public.access.forms
Allen Browne
external usenet poster
 
Posts: 11,706
Default Control Validation

Yep: exactly what we said.
The events of the control won't work.

Use the *form's* BeforeUpdate event (not the control's event), or the field
properties in the table.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Confused Slug" wrote in message
...
I am currently using the the following code in the beforeupdate event,

Private Sub DESCRIPTION_22_BeforeUpdate(Cancel As Integer)

If IsNull(DESCRIPTION_22) = True Then
MsgBox "Enter text"
Cancel = True

End If

End Sub

I have found that the validation does not take place until the field has
had
a value in it. When a new record is created i find that you can tab out of
the control without entering any text. Only when text has been added and
deleted does the validation event occur.


"Allen Browne" wrote:

Open the table in design view, and set the field's Required property to
Yes.

If you prefer to use the Validation Rule of the field in the table:
Is Not Null

If you want to do it in a form, use the BeforeUpdate event of the form to
test it the control IsNull(). You cannot merely use the Validation Rule
of
the control, since that is not triggered if nothing is entered.

"Confused Slug" wrote in message
...
What is the best expression to use in the Validate property for a
control
to
test that some text (of unconstrained length) has been entered.



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:42 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.