Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Infopath - adding a time and date field

Status
Not open for further replies.

superrug

Technical User
Jun 18, 2003
19
0
0
GB
Ive just started using this software i have designed my form but am having slight problems with some of the controls. I want to add a time and date field that automatically fills when the form is opened. Also i would like to add a button at the bottom that will save the document as the file name in one of the fields on the form.

Anyone have any ideas, i tried for a couple of days and it appears i am beaten !
 
If you want to fill date and time fields in you could put that in the form initialize in the form:

Code:
Private Sub UserForm_Initialize()

    ' Add the date
    TextBox1.Value = Date

End Sub

That would add the date the form is opened. To save the document you could look at posts refering to the common diaglog box.



Mark Davies
Warwickshire County Council
 
To prelaod a date, create a rule for that field which sets itself to Now() or today() (now provides the date and time and today only provides the date.
 
Hi superrug,

For the date, you could also use one of Word's inbuilt date fields:
DATE - shows the current date (and time if you use the appropriate picture switch (eg DATE \@ "HH:MM dddd, dd mmm yy")), and updates whenever the document is opened.
CREATEDATE - shows the document's creation date (and time if you use the appropriate picture switch), and updates only if the file is saved via 'Save As'.
PRINTDATE - shows the last-printed date (and time if you use the appropriate picture switch), and updates whenever the document is printed.
SAVEDATE - shows the last-saved date (and time if you use the appropriate picture switch), and updates whenever the document is saved.

For the filename, you could use the FILENAME field. With the \p switch (eg FILENAME \p), this field also returns the full path to the document. Without that switch you just get the filename.

For more info, check out Insert|Field and/or Word's help file.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top