# Thread: Calculating a date (Access97)

1. ## Calculating a date (Access97)

I have a form called Date_frm. On this form are 2 fields FirstDate and EndDate. What I would like to do is have the user enter into the Firstdate field the first day of the month ie:10/01/02. Them I would like for them to press a button and have the EndDate field calculate what the last day of the date entered into the FirstDate field is. Ie: 10/31/02. Does any know how to do this? Thanks..

2. ## Re: Calculating a date (Access97)

There are several ways to do this.

You could use the following expression as Control Source for the EndDate text box:

=DateSerial(Year([FirstDate]), Month([FirstDate]) + 1, 0)

If you're going to use this kind of formula a lot, you might create a user defined function in a standard module:

Public Function EndOfMonth(d)
If IsDate(d) Then
EndOfMonth = DateSerial(Year(d), Month(d) + 1, 0)
End If
End Function

and use it in the Control Source as

=EndOfMonth([FirstDate])

3. ## Re: Calculating a date (Access97)

Thanks worked great...

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•