Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Access Problem validating text field

Posted on 2007-04-04
6
Medium Priority
?
892 Views
Last Modified: 2010-05-18
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.

0
Comment
Question by:frinpd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 4

Accepted Solution

by:
jcampanali earned 2000 total points
ID: 18851102
You don't need code.
Use the validation rule property in design view of the form for the selected text box.
Simply put Not Null in the Validation Rule and in Validation Text put the message you want the user to see.

You can do code for more customization if this does not meet your requirements.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 18851113
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
0
 
LVL 13

Expert Comment

by:wiswalld
ID: 18851119
What about a button with this

If IsNull Me.Textbox Then
Msgbox "Textbox is empty"
Else
End If
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 75
ID: 18851155
wiswalld

"If IsNull Me.Textbox Then"

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

mx
0
 
LVL 75
ID: 18851194
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
0
 

Author Comment

by:frinpd
ID: 18851286
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.
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question