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  

validation for one field based on another



 
 
Thread Tools Display Modes
  #1  
Old March 29th, 2010, 07:37 PM posted to microsoft.public.access.tablesdbdesign
andrew w[_2_]
external usenet poster
 
Posts: 1
Default validation for one field based on another

I have two fields and I wish to validate one to depend on the other

This what I would like to happen

if field1 = text1 or text2 or text3
field2 must be populated
If field1 = text4 or text5
Field2 does not need to be populated

Field1 is a drop down menu with 5 text options field2 is an integer I want
field2 dependent on field 1
I have tried the iif function at table level and it didn't work is there
another option?
I'm using 2003
Ads
  #2  
Old March 29th, 2010, 08:00 PM posted to microsoft.public.access.tablesdbdesign
Steve[_77_]
external usenet poster
 
Posts: 1,017
Default validation for one field based on another

I'm going to assume that Field1 gets its values from a table named TblMenu
and the primary key is MenuID. Further I am assuming that Field1 combobox
displays Text1, Text2, Text3, Text4 or Text5 but actually has the value 1,
2, 3, 4 or 5.

A form's BeforeUpdate event fires when a value has been added, deleted or
edited in any control on a form. To do what you want, put the following code
in the form's BeforeUpdate event:
Select Case Me!Field1
Case 1,2,3
If IsNull(Me!Field2) Then
MsgBox "Field2 Must Be Populated"
Cancel = True
End If
Case Else
End Select

Steve





"andrew w" andrew
wrote in message
...
I have two fields and I wish to validate one to depend on the other

This what I would like to happen

if field1 = text1 or text2 or text3
field2 must be populated
If field1 = text4 or text5
Field2 does not need to be populated

Field1 is a drop down menu with 5 text options field2 is an integer I want
field2 dependent on field 1
I have tried the iif function at table level and it didn't work is there
another option?
I'm using 2003



 




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 02:07 AM.


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