If statements

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

In excel, I can use an IF statement to give me an answer
based on blank values in a cell: If(a1="","empty","full")
"" represents a blank answer.

I would like to do the same for a field in Access using
IIF or any function that can do it.

I have a field that has a date in it and another field
that uses the date field to perform a calulation (ie
=datediff). I would like the calculation field to be blank
if the date field is blank.
 
Are you talking about the DatasheetView of the Table?

If yes, you should not store the Calculated value as the Table Field.
Storing calculated values violates the 3rd Normal Form of Database
Normalisation (a set of rules to ensure efficient but flexible storage of
data, e.g. no duplicated data).

If you are talking about Query or (Controls) on Form, you can use the
expression posted by Wayne. Actually, there is a typo in Wayne's expression
(a closing parenthesis was omitted) . It should be:

=IIf(IsNull([DateField]), "", DateDiff(what ever here))
 
Back
Top