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
Solved

Access Problem validating text field

Posted on 2007-04-04
6
855 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
6 Comments
 
LVL 4

Accepted Solution

by:
jcampanali earned 500 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
update query 4 25
Error can't find table ?? 5 24
SetProperty Foreground Colour 5 14
2 subforms 1 main form 1 13
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
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…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

856 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