Solved

Access Problem validating text field

Posted on 2007-04-04
6
832 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
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DSum for Access 6 43
running an update statement after a msgbox (MS Access) 3 28
Sub Reports 8 21
MS Access 03, TransferText, decimal places 8 37
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

914 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now