Field Values using If Else statements

M

MJc215

I want to create a field that has a numeric value that will be
determined by another already created field called "days out". I want
the days out field to be worked into an If else statement that will
enter a value of 1, 2, or 3 based the number of days out field. Can i
write this directly in the field or should it be done with a function
that is referenced to the field?????
 
V

Van T. Dinh

No.

In fact, calculated values (and it sounds to me the required numeric value
you want is a calculated value) should not be stored in the Table according
to the Relational Database Design Theory. Calculated values should
generally be (re-) calculated when it is needed and not stored!
 
T

tina

well, unless there is a direct 1 to 1 correlation between [days out] and the
assigned value (1 [days out] = 1 [assigned value], 2 [days out] = 2
[assigned value], etc), i would probably use a Select Case statement. for
example

Select Case Me![days out]
Case 1 To 5
Me![days out] = 1
Case 6 To 10
Me![days out] = 2
Case Is > 10
Me![days out] = 3
Case Else
Me![days out] = 0
End Select

you might run the code from the [days out] control's AfterUpdate event
procedure.

hth
 
Top