View Single Post
  #4  
Old February 17th, 2010, 05:52 PM posted to microsoft.public.access.tablesdbdesign
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Validating two fields

On Wed, 17 Feb 2010 08:26:03 -0800, CorpTrainer570
wrote:

Thanks for the reply, but is there a way to create a validation rule that
would specifically look for words. for example:

in the "Type of Document" column there are three options: "nursing report",
"progress note", incident report". Depending on what type of document is
selected, certain fields should be required to filled in.

If "nursing report" than "type of injury" must be filled in.
If "progress note" than "program" must be filled in.
If "incident report" than "Description of incident" must be filled in.


A validation rule would be a really awkward way to do this - the BeforeUpdate
event of a Form would be much better and more user friendly. That said, a
table validation rule (*NOT* a field validation rule) might be:

([Type Of Document] = "Nursing Report" AND [Type Of Injury] IS NOT NULL)
OR
([Type Of Document] = "Progress Note" AND [Program] IS NOT NULL)
OR
([Type Of Document] = "Incident Report" AND [Description Of Incident] IS NOT
NULL)

The validation text would be snarky, because it will be displayed identically
regardless of which case occurred - you can customize the message in the VBA
code of the BeforeUpdate event, but you can't here.
--

John W. Vinson [MVP]