0

Hi,

I'm trying to build an Access database on Access 2007 and I'm unsure of how to do a few things.

I have 2 fields: field1 and field2. Both are dates. I want field2 to change to exactly a month after the date in field1 and I want it to appear right when the date in field1 is entered. Also, I don't want field2 to be altered by the user.

How do I do that?

Thanks

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by ChrisPadgham
0

Dear John

First make a form with two date fields

Lets call first one as Firstdate and second one as Seconddate

Go to Designview of Form

On property sheet of the Seconddate - at Data tab, Change "Enabled" into "No" and "Locked" to "Yes"

On property sheet of the Firstdate - at Event tab, After update, select Event Procedure, and type the following
Private Sub FirstDate_AfterUpdate()
Dim FD As Date
Dim StrFD As String
Dim SD As Date
FD = Me.FirstDate
StrFD = CStr(FD)
SD = DateAdd("m", 1, StrFD)
Me.SecondDate = SD
End Sub

Close all after saving

Open Form and enter any date in first date field and hey presto Your second date is ready

Hope this solves the problem

If you can send me your emailID, i can send a copy of database.

Dilton1958

0

Doesn't sound like you should be storing the second date in a field, put a text box on the screen and in its control source put the expression

=dateadd("m",1, me.firstdate)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.