A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Conditional Formating - Validation



 
 
Thread Tools Display Modes
  #1  
Old December 6th, 2005, 06:09 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Conditional Formating - Validation

I have 2 fields on the form. If one is filled in, the other one needs to be
as well.
However, they both can be blank.

Any ideas?
  #2  
Old December 6th, 2005, 06:27 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Conditional Formating - Validation

You can use the Before Update event of the form to check for this condition:
Warning! Untested Air Code

If (IsNull(Me.TextBox1) And Not IsNull(Me.TextBox2)) Or _
(Not (IsNull(Me.TextBox1) And IsNull(Me.TextBox2))) Then
Then MsgBox "Both Text Boxes Must Be Filled In"
Cancel = True
End If

"JB" wrote:

I have 2 fields on the form. If one is filled in, the other one needs to be
as well.
However, they both can be blank.

Any ideas?

  #3  
Old December 8th, 2005, 11:18 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Conditional Formating - Validation

Let me introduce you to the wonders of a truth table

Length Length
Field1 Field2 Result Action
0 0 VALID No Information Present
0 1 VALID Information missing
1 0 VALID Information missing
1 1 VALID Information present

From there just build your If...Thens as in

If Len(Field1) = 0 AND Len(Field2) = 0 Then

If (Len(Field1) = 0 AND Len(Field2) 0) OR (Len(Field1) 0 AND
Len(Field2) = 0) Then

If Len(Field1) 0 AND Len(Field1) 0 Then

In this situation, I assumed that the validation is simple in that the a
character is in either field. If the validation criteria is different,
adapting the above, shouldn't be that difficult.

For more on truth tables...

http://en.wikipedia.org/wiki/Truth_table

David H


JB wrote:
I have 2 fields on the form. If one is filled in, the other one needs to be
as well.
However, they both can be blank.

Any ideas?

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional formating using formulas arifnj Worksheet Functions 4 October 27th, 2005 01:56 PM
VLOOKUP & Conditional Formating Help. Excel'ed Failures General Discussion 6 August 16th, 2005 04:46 PM
Conditional validation :-) Robert General Discussion 1 February 18th, 2005 08:07 AM
Conditional Formating in Report Header Haas Setting Up & Running Reports 1 July 21st, 2004 10:50 PM
Conditional Formating Brw Worksheet Functions 3 December 9th, 2003 03:12 PM


All times are GMT +1. The time now is 01:00 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.