Link to home
Start Free TrialLog in
Avatar of frinpd
frinpd

asked on

Access Problem validating text field

How can i add validation in Microsoft  Access Text Box Form to check to see if value entered in text box is not null. Also where should i put the code. I am using Access first time so please explain in detail with code.
Also i have link table using Oracle odbc.

I have form like this

Div_code <Text Field>
Div_Desc<Text Field>

I want to validate on both above field.

ASKER CERTIFIED SOLUTION
Avatar of jcampanali
jcampanali

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mbizup
In the before update event of your form:

If nz(me.div_code,"") = "" then
   msgbox "please Enter div code"
   Cancel = true
   exit sub
end if
If nz(me.div_desc,"") = "" then
   msgbox "please Enter div desc"
   Cancel = true
   exit sub
end if
What about a button with this

If IsNull Me.Textbox Then
Msgbox "Textbox is empty"
Else
End If
wiswalld

"If IsNull Me.Textbox Then"

You need to encapuslate Me.Textbox  If IsNull(Me.Textbox) Then ....

mx
Also ... if you go the Validation Rule route, it would be a good idea to put some code in the Form Error event to trap Error 7753 ... which occurs when a validation rule is not meant ... the purpose being to display a more 'user friendly' error message than the default Access error message ....

mx
Avatar of frinpd
frinpd

ASKER

jcampanali:

I follow your answer and in property box of Div_code i put not null in validation rule i put not null and in validation text i put "Div code should not be empty".

The problem is even after i enter value in div code the dialog box appear with text saying "Div code should not be empty" and cursor does not move to next field.

Please advise.