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

Recommended Answers

All 2 Replies

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

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)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.