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 » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Validating two fields



 
 
Thread Tools Display Modes
  #1  
Old February 13th, 2010, 01:16 AM posted to microsoft.public.access.tablesdbdesign
CorpTrainer570
external usenet poster
 
Posts: 3
Default Validating two fields

I am trying to create a database in which some of the fields should be
mandatory only under certain conditions.

For example:

In my "Type of Injury" column, I want the user to be required to enter a
value in this column, only if the value in the "Type of Document" column is
"Nursing Report". Is this possible? I am only just beginning to teach
myself Access, so please bear with me. Thank you.
  #2  
Old February 13th, 2010, 02:56 AM posted to microsoft.public.access.tablesdbdesign
Allen Browne
external usenet poster
 
Posts: 11,706
Default Validating two fields

Put a validation rule on the *table* (not field.)

2nd example under the the Validation Rules for Tables section he
http://allenbrowne.com/ValidationRule.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"CorpTrainer570" wrote in message
...
I am trying to create a database in which some of the fields should be
mandatory only under certain conditions.

For example:

In my "Type of Injury" column, I want the user to be required to enter a
value in this column, only if the value in the "Type of Document" column
is
"Nursing Report". Is this possible? I am only just beginning to teach
myself Access, so please bear with me. Thank you.


  #3  
Old February 17th, 2010, 05:26 PM posted to microsoft.public.access.tablesdbdesign
CorpTrainer570
external usenet poster
 
Posts: 3
Default Validating two fields

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.

"Allen Browne" wrote:

Put a validation rule on the *table* (not field.)

2nd example under the the Validation Rules for Tables section he
http://allenbrowne.com/ValidationRule.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"CorpTrainer570" wrote in message
...
I am trying to create a database in which some of the fields should be
mandatory only under certain conditions.

For example:

In my "Type of Injury" column, I want the user to be required to enter a
value in this column, only if the value in the "Type of Document" column
is
"Nursing Report". Is this possible? I am only just beginning to teach
myself Access, so please bear with me. Thank you.


.

  #4  
Old February 17th, 2010, 06: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]
 




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


All times are GMT +1. The time now is 11:23 PM.


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