469,268 Members | 942 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,268 developers. It's quick & easy.

Validation Rule for Not Null value

Hi,

How to set Validation Rule?

Example, my Textbox should not be empty. So, I set validation rule as "Not null". But it shows only at the end of record save.

I must need to show when they leave from textbox itself. Not at the end of the record. And,I need to show my Own message

Can anybody please suggest me?

Thanks in advance.

ngr.
Apr 14 '07 #1
6 29471
Rabbit
12,516 Expert Mod 8TB
Do it using code in the lost focus event of the textbox.
Apr 14 '07 #2
Do it using code in the lost focus event of the textbox.
============

Hi,

I just tried as below in the lost focus.

If Not IsNull(Me!Text1) Then
MsgBox "Eh..! It cannot be Empty."
End If

Is it correct?.

It says when I leave the textbox/combo box empty. But, It also shows the same message even when i fill the textbox. How could the same message comes even i filled the control?

Further, it also allows me to move to the next control. I need to stop when the control is blank in the current control itself. I used the below code.

Docmd.GoToControl (text1)

Is it correct..?

Pls.suggest me.

Thanks in advance.

ngr.
Apr 16 '07 #3
you may try to this

<>0


put that in the validation rule
Apr 16 '07 #4
or set the field property to required = yes...sory about my last post...its applicable for combo box calling number values
Apr 16 '07 #5
or set the field property to required = yes...sory about my last post...its applicable for combo box calling number values
=====

Hi,

Thnx for your info...

But, i m totally confused.(rrrrhhh....)

Anyhow, Please let me know the steps.

1. In the Table design, i hve set "<>0" value for combobox and "Not null" value for textbox. Do I Want to write the same RULE on the control in the form designs?

2. How do i display my own message?. What should i write in combobox/textbox_lostfocus event?. When the error comes,it should not allow to move next text/combo box?

Whatever i had written is not working properly.

To conclude this 2 condition, pls write simply code that should i use..

I becoming MAD since morning.

Thanks in advance.

ngr.
Apr 16 '07 #6
Rabbit
12,516 Expert Mod 8TB
============

Hi,

I just tried as below in the lost focus.

If Not IsNull(Me!Text1) Then
MsgBox "Eh..! It cannot be Empty."
End If

Is it correct?.

It says when I leave the textbox/combo box empty. But, It also shows the same message even when i fill the textbox. How could the same message comes even i filled the control?

Further, it also allows me to move to the next control. I need to stop when the control is blank in the current control itself. I used the below code.

Docmd.GoToControl (text1)

Is it correct..?

Pls.suggest me.

Thanks in advance.

ngr.
The Not shouldn't be there. Not IsNull means if it's not null. You may also want to try IsEmpty instead.

To keep the focus on that control, use the code you posted or use Me.ControlName.SetFocus

Except in your code you need to surround the name of the control with quotes.
Apr 16 '07 #7

Post your reply

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

Similar topics

30 posts views Thread by Dr John Stockton | last post: by
3 posts views Thread by Dalan | last post: by
2 posts views Thread by Doslil | last post: by
2 posts views Thread by Danny | last post: by
5 posts views Thread by Don Sealer | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.