Solved

Access Problem validating text field

Posted on 2007-04-04
6
816 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
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 
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.

Join & Write a Comment

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…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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

21 Experts available now in Live!

Get 1:1 Help Now