Fire only when not empty: Access 2000

  • Thread starter Thread starter Gale Coleman
  • Start date Start date
G

Gale Coleman

Hello all,

I have a field in my form called BDATE.

When I press the Toggle91 button I want it to first check to see if BDATE is
populated and if it is, then go on with changing the Age field. I got it to
change the age correctly when the button is pushed. I just don't know how
to tell it not to calculate age if there is nothing in the BDATE field. Any
suggestions?

Thanks
Gale


Private Sub Toggle91_GotFocus()
Dim dtmDate As Date
dtmDate = Date
Me!AGE = DateDiff("yyyy", Me!BDATE, dtmDate) + (dtmDate <
DateSerial(Year(dtmDate), Month(Me!BDATE), Day(Me!BDATE)))
End Sub
 
Why make them click a button? Just make your AGE field an unbound text box
with your formula in it.

You don't store AGE since it is a moving target, so just display it in an
unbound field. No need for code, buttons, conditions, etc.

You could modify your formula so no error displays if Birthdate is blank.
 
Hi Rick,

Yes, we do store the ages. We have to as we provide certain services by the
ages of the people and need to be able to make different queries and reports
regarding age.

What I am trying to do it modify the code so no error displays if the
Birthdate is blank.

Thanks,

Gale
 
You should not (as posted HUNDREDS OF TIMES) store age. That is a
calcualted field. It is a moving target. You mean you go in and update
every age in your table everyday?

Instead, add a new field to your queries and calculate the age there . Then
you can use a parameter to evaluate it. Your new column would be....


Age: If
isnull([Birthdate],"",DateDiff("yyyy",[Birthdate],Date())+(Format([Birthdate
],"mmdd")>Format(Date(),"mmdd")))
 
Thanks Rick,

I have read some of the posts. This program was made by someone other than
myself. It was made for certain purposes and I was just trying to make if
work better for our agency without totally screwing up the whole goal behind
storing the ages.

I have figured it out now.

Thanks.

Gale
 
Back
Top