Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Check boxes and user names in forms
I would like to create a checklist in Word using a form. The in-built Help gives a good description on how to create a form and add check-boxes to it, but I would like also to have fields next to the check boxes which auto-populate with the user name when the check box is set, and another field which auto-fills the time the check box was ticked. Any advice or suggestions gratefully received.
|
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Check boxes and user names in forms
If you assign the bookmark names checkname to the checkbox and textname to
the formfield in which you want the user name to be displayed and texttime to the formfield in which you want the time to be displayed and you run a macro containing the following code on exit from the checkname checkbox, it will populate the textname and texttime formfields with the name of the user and the time at which the checkbox was checked respectively. With ActiveDocument If .FormFields("checkName").CheckBox.Value = True Then .FormFields("textName").result = Application.UserName .FormFields("textTime").result = Format(Now, "yyyy-mm-dd - hh:MM:ss") Else .FormFields("textName").result = "" .FormFields("textTime").result = "" End If End With Modify the format string to get the time in the format that you want it. Check out the Format function in the visual basic help file to see the various options. -- 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, originally posted via msnews.microsoft.com "TobyR" wrote in message ... I would like to create a checklist in Word using a form. The in-built Help gives a good description on how to create a form and add check-boxes to it, but I would like also to have fields next to the check boxes which auto-populate with the user name when the check box is set, and another field which auto-fills the time the check box was ticked. Any advice or suggestions gratefully received. -- TobyR |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Check boxes and user names in forms
If you assign the bookmark names checkname to the checkbox and textname to
the formfield in which you want the user name to be displayed and texttime to the formfield in which you want the time to be displayed and you run a macro containing the following code on exit from the checkname checkbox, it will populate the textname and texttime formfields with the name of the user and the time at which the checkbox was checked respectively. With ActiveDocument If .FormFields("checkName").CheckBox.Value = True Then .FormFields("textName").result = Application.UserName .FormFields("textTime").result = Format(Now, "yyyy-mm-dd - hh:MM:ss") Else .FormFields("textName").result = "" .FormFields("textTime").result = "" End If End With Modify the format string to get the time in the format that you want it. Check out the Format function in the visual basic help file to see the various options. -- 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, originally posted via msnews.microsoft.com "TobyR" wrote in message ... I would like to create a checklist in Word using a form. The in-built Help gives a good description on how to create a form and add check-boxes to it, but I would like also to have fields next to the check boxes which auto-populate with the user name when the check box is set, and another field which auto-fills the time the check box was ticked. Any advice or suggestions gratefully received. -- TobyR |
#4
|
|||
|
|||
Many thanks for the advice Doug - does this mean however (as I think it does) that I will need one macro per checkbox I want to track in this way?
Quote:
|
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Check boxes and user names in forms
See response to your original post.
-- 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, originally posted via msnews.microsoft.com "TobyR" wrote in message ... Moderators please delete - post worked first time round! MS Word 2007 help has a good section on how to create a form with check boxes (using legacy controls) but I would like to do something a little more complex, namely having fields next to the checkbox which update with the the username of the person setting the check box and the date the check box is set. Is this possible? Any advice or suggestion gratefully received. -- TobyR |
#6
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Check boxes and user names in forms
See response to your original post.
-- 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, originally posted via msnews.microsoft.com "TobyR" wrote in message ... Moderators please delete - post worked first time round! MS Word 2007 help has a good section on how to create a form with check boxes (using legacy controls) but I would like to do something a little more complex, namely having fields next to the checkbox which update with the the username of the person setting the check box and the date the check box is set. Is this possible? Any advice or suggestion gratefully received. -- TobyR |
#7
|
|||
|
|||
Indeed, I did post a second time when I thought my first post didn't work - sorry for the confusion. But to reiterate my last question, would I have to create a separate macro for each checkbox/text-field grouping? If so, is there some way to avoid this as I have in mind a form with about 50 check boxes.
Quote:
|
#8
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Check boxes and user names in forms
How do you have all of the checkboxes and other formfields arranged?
If they each checkbox and the Name and Time text formfields associated with it were all in a one row of a table in the order Checkbox, Name formfield, Time formfield, then you should be able to use the following code on exit from each of the check boxes With Selection.Rows(1).Range If .FormFields(1).CheckBox.Value = True Then .FormFields(2).result = Application.UserName .FormFields(3).result = Format(Now, "yyyy-mm-dd - hh:MM:ss") Else .FormFields(2).result = "" .FormFields(3).result = "" End If End With -- 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, originally posted via msnews.microsoft.com "TobyR" wrote in message ... Indeed, I did post a second time when I thought my first post didn't work - sorry for the confusion. But to reiterate my last question, would I have to create a separate macro for each checkbox/text-field grouping? If so, is there some way to avoid this as I have in mind a form with about 50 check boxes. Doug Robbins - Word MVP;460299 Wrote: See response to your original post. "TobyR" wrote in message ...- Moderators please delete - post worked first time round! MS Word 2007 help has a good section on how to create a form with check boxes (using legacy controls) but I would like to do something a little more complex, namely having fields next to the checkbox which update with the the username of the person setting the check box and the date the check box is set. Is this possible? Any advice or suggestion gratefully received. -- TobyR - -- TobyR |
#9
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Check boxes and user names in forms
How do you have all of the checkboxes and other formfields arranged?
If they each checkbox and the Name and Time text formfields associated with it were all in a one row of a table in the order Checkbox, Name formfield, Time formfield, then you should be able to use the following code on exit from each of the check boxes With Selection.Rows(1).Range If .FormFields(1).CheckBox.Value = True Then .FormFields(2).result = Application.UserName .FormFields(3).result = Format(Now, "yyyy-mm-dd - hh:MM:ss") Else .FormFields(2).result = "" .FormFields(3).result = "" End If End With -- 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, originally posted via msnews.microsoft.com "TobyR" wrote in message ... Indeed, I did post a second time when I thought my first post didn't work - sorry for the confusion. But to reiterate my last question, would I have to create a separate macro for each checkbox/text-field grouping? If so, is there some way to avoid this as I have in mind a form with about 50 check boxes. Doug Robbins - Word MVP;460299 Wrote: See response to your original post. "TobyR" wrote in message ...- Moderators please delete - post worked first time round! MS Word 2007 help has a good section on how to create a form with check boxes (using legacy controls) but I would like to do something a little more complex, namely having fields next to the checkbox which update with the the username of the person setting the check box and the date the check box is set. Is this possible? Any advice or suggestion gratefully received. -- TobyR - -- TobyR |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do i add check boxes to my letters or forms | Page Layout | |||
Spell Check in Forms Text Boxes? | Microsoft Word Help | |||
I need help with check boxes in creating forms in Word | Microsoft Word Help | |||
User Forms and Combo boxes in Work | Microsoft Word Help | |||
Using check boxes within forms and email | Microsoft Word Help |