From: andrew w andrew on 29 Mar 2010 14:37 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
From: Steve on 29 Mar 2010 15:00 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 santus(a)penn.com "andrew w" <andrew w(a)discussions.microsoft.com> wrote in message news:7F52891F-D299-4734-BFD7-2CA5DD9C7FEA(a)microsoft.com... >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
|
Pages: 1 Prev: dumb data type question Next: Prevent duplicate groups of records in a table |