Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    If User Clicks Checkbox on Form then Focus is sent (English/Word2k/OfficeX

    I've created a form in Word 2k that will be protected. The typical user of this form will mouse click on checkboxes rather than TAB around. I need some code so that when a user clicks on the NO checkbox, the box is enabled (an X is entered into it) and the focus is set to another field at the back of the form. The code I have currently is:

    Sub TaskCodeNo_Click()

    Dim vTaskCodNo
    Set vTaskCodeNo = ActiveDocument.FormFields("TaskCodeNo").CheckBox

    If vTaskCodeNo.Value = True Then
    ActiveDocument.Bookmarks("DescOfWork").Range.Field s(1).Result.Select

    End If

    End Sub

    I'm missing something important to set the focus on the "DescOfWork" text field.

    Can anyone please help?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: If User Clicks Checkbox on Form then Focus is sent (English/Word2k/Off

    A check box from the Forms toolbar does not really have an On Click event. The best you can do (I think) is to specify TaskCodeNo_Click both as On Enter macro and as On Exit macro for the check box.

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: If User Clicks Checkbox on Form then Focus is

    Regarding the last question, does it work if you get there via the FormFields collection rather than the Bookmarks collection?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: If User Clicks Checkbox on Form then Focus is

    According to <A target="_blank" HREF="http://www.word.mvps.org/faqs/tblsfldsfms/SetTabOrder.htm">How to set the

  5. #5
    New Lounger
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If User Clicks Checkbox on Form then Focus is

    Hans,

    Thank you very much for your help. The solution worked great. However, it only worked one time. As a user, if I click on the checkbox so that it is disabled, and then check again to re-eanble it, the focus transfer does not work a second time. Is there any code I can use that will allow the transfer of focus to be used whenever the user clicks on the TaskCodeNo checkbox?

    Thanks

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: If User Clicks Checkbox on Form then Focus is

    As I noted, the check box from the Forms toolbar does not have an On Click event, only an On Enter and an On Exit event.

    If the check box is off and you click it, you turn it on, and the On Enter macro moves focus to DescOfWork.
    If the check box is on and you click it, you turn it off, and the On Enter macro does nothing. If you then click the check box again, you turn it on, but since it already had the focus, neither the On Enter event nor the On Exit event occurs. Only when you move away from the check box does the On Exit macro occur.

    If it is important to you that the focus is transferred to DescOfWork immediately, you cannot use the Forms check box. Use the check box from the Control Toolbox instead, and write code for its On Click event.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •