Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / July 2007

Tip: Looking for answers? Try searching our database.

populating form fields from a single date

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Linda Fiske - 21 Jul 2007 04:20 GMT
Hi:
This is an example of the kind of template I am trying to create:

      July 23, 2007   to   July 27, 2007

     MONDAY - 23
    TUESDAY - 24
    WEDNESDAY - 25
    THURSDAY - 26
    FRIDAY - 27
    DR. ASSIGNMENT

I would like the user to be able to input the beginning date (for example
"July 23, 2007" ) and have the rest of the fields automatically populate,
i.e.,  have the "to July 27, 2007" field populate by adding 5 days to the
beginning date; have Monday's date be extracted from the beginning date; and
Tuesday's date be extracted from the beginning date by adding 1, Wednesday
by adding 2, etc.

Is this possible???  Any guidance on how would be greatly appreciated.

Gratefully,
Linda
Doug Robbins - Word MVP - 22 Jul 2007 08:37 GMT
For the following macro, which you would set to run on exit from the
formfield into which the user enters the starting date, I have given
meaningful bookmark names to each of the formfields

Dim sdate As Date
Dim sday As Integer
With ActiveDocument
   If IsDate(.FormFields("Start").Result) Then
       sdate = .FormFields("Start").Result
       sday = Format(sdate, "d")
       .FormFields("Finish").Result = Format(DateAdd("d", 4, sdate), "MMMM
dd, yyyy")
       .FormFields("Monday").Result = "Monday " & Format(sday, "0#")
       .FormFields("Tuesday").Result = "Tuesday " & Format(sday + 1, "0#")
       .FormFields("Wednesday").Result = "Wednesday " & Format(sday + 2,
"0#")
       .FormFields("Thursday").Result = "Thursday " & Format(sday + 3,
"0#")
       .FormFields("Friday").Result = "Friday " & Format(sday + 4, "0#")
   Else
       MsgBox "You did not input a valid date."
   End If
End With

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Hi:
> This is an example of the kind of template I am trying to create:
[quoted text clipped - 20 lines]
> Gratefully,
> Linda
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.