General discussion

Locked

Support for questions MS Office Xp 2002

By gene.a.newton ·
" I am using Office XP (2002) on Windows 2000. I'm trying to
design a form where the user would enter a date and another field would
calculate that date and add 6 months to it.

Example:
License valid June 27, 2002 (user fills in this date)
License expires December 27, 2002 (this date is calculated
automatically using the previously entered date)"

The only answer I have been able to get so far is that I need to write a
macro using VBA for this. I don't know how to write macros using VBA so this
isn't very much help for me.

Any ideas on where I can get support for these types of issues would be
greatly appreciated.

This conversation is currently closed to new comments.

8 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Support for questions MS Office Xp 2002

by DKlippert In reply to Support for questions MS ...

Is this form in Word, Excel, or Access?

Collapse -

Support for questions MS Office Xp 2002

by gene.a.newton In reply to Support for questions MS ...

It is a Word Document

Collapse -

Support for questions MS Office Xp 2002

by gene.a.newton In reply to Support for questions MS ...

It is a Word document

Collapse -

Support for questions MS Office Xp 2002

by DKlippert In reply to Support for questions MS ...

Attach this macro to the Form document.

Sub ExitValidDate()
Dim dtValidDate As Date, dtExpireDate As Date

' what you get from the form...

dtValidDate = _
CDate(ActiveDocument.FormFields("ValidDate").Result)

' do the date math

dtExpireDate = _
DateAdd(interval:="M", Number:=6, Date:=dtValidDate)

' fill the textboxes in the form

ActiveDocument.FormFields("ExpireDate").Result = dtExpireDate
End Sub

Assign this macro as the exit macro of the ValidDate form field. It will populate the ExpireDate field as soon as the user tabs out of the ValidDate field. It will work in a protected form.


(Adapted from
www.mvps.org/word/FAQs/MacrosVBA/DateOfPrevMonth.htm

and a macro written by Jay Freedman on the

microsoft.public.word.vba.beginners

forum)

Collapse -

Support for questions MS Office Xp 2002

by gene.a.newton In reply to Support for questions MS ...

Poster rated this answer

Collapse -

Support for questions MS Office Xp 2002

by timwalsh In reply to Support for questions MS ...

First I would suggest going with 180 days vs. 6 months. This would alleviate the need to take into account differing month lengths and prevents answers such as:
valid 31 Aug 02
expires 31 Feb 03.

Assuming this will work for your particular application, I would embed a simple 2 cell spreadsheet in the Word document. Format both cells as dates (using whichever date format works for you). In the second cell (expiration date), enter the formula =A1+180 (this assumes the reference for thefirst cell is A1). There is probably a way to do the same thing using a table directly in Word.

Hope this helps.

Collapse -

Support for questions MS Office Xp 2002

by gene.a.newton In reply to Support for questions MS ...

Poster rated this answer

Collapse -

Support for questions MS Office Xp 2002

by gene.a.newton In reply to Support for questions MS ...

This question was closed by the author

Back to Software Forum
8 total posts (Page 1 of 1)  

Related Discussions

Related Forums