Fire only when not empty: Access 2000

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
 
R

Rick B

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.
 
G

Gale Coleman

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
 
R

Rick B

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")))
 
G

Gale Coleman

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top