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 / August 2006

Tip: Looking for answers? Try searching our database.

Setting a checkbox field to the value received from Form/Screen

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeffery B Paarsa - 14 Aug 2006 00:14 GMT
In a Word VBA code I am displaying a Form/Screen with lots of Checkboxes on
the form to the user.  I would like to set the value of check boxes on the
word document to the value of check boxes coming from the form/screen by the
user.  Here is the code I use:

Calling subroutine:

Private Sub CMDPage4N_Click()
With ActiveDocument
.Unprotect
UpdateCheckBox "SWgtLoss", ChkB01.Value
.Protect wdAllowOnlyFormFields
UserForm1.MultiPage1.Value = MultiPage1.Value + 1
End With
End Sub

Here is the Called Subroutine:

Public Sub UpdateCheckBox(BookmarkToUpdate As String, BoolData As Boolean)
   Dim BMRange As Range
   Set BMRange = ActiveDocument.Bookmarks(BookmarkToUpdate).Range
   With ActiveDocument.FormFields(BookmarkToUpdate).CheckBox
     .Value = BoolData
   End With
End Sub

I turned on the debug on the following line in the calling subroutine:
UpdateCheckBox "SWgtLoss", ChkB01.Value
Having the document open at the back of the debug screen I can see the
related check box field is being set to X but as soon as I come out go to the
following line:
UserForm1.MultiPage1.Value = MultiPage1.Value + 1
my check box tunes into unchecked box and X is being removed.  I think I
know I have call by value problem but I have used 3-4 hours to resolve this
problem and keep the X in the box with no success.  Any suggestion?



Signature

Jeff B Paarsa

Jezebel - 14 Aug 2006 00:40 GMT
I assume that "form/screen" is your own term for "UserForm". (The word
'form' usually means a document with formfields.)

1. When you re-protect the document, you need to use the 'noreset' argument.
Otherwise the formfields are cleared --

activedocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=true

2. In your UpdateCheckBox code you set BMRange, but then don't refer to it.
What did you have in mind with this?

> In a Word VBA code I am displaying a Form/Screen with lots of Checkboxes
> on
[quoted text clipped - 35 lines]
> this
> problem and keep the X in the box with no success.  Any suggestion?
Jeffery B Paarsa - 14 Aug 2006 06:54 GMT
Thank you it worked... Regarding the unsed variable ignore it I just tried to
post the code as brief as I could and I forgot to take them out...
Signature

Jeff B Paarsa

> I assume that "form/screen" is your own term for "UserForm". (The word
> 'form' usually means a document with formfields.)
[quoted text clipped - 46 lines]
> > this
> > problem and keep the X in the box with no success.  Any suggestion?
 
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.