Hello,
in an template which creates various numbers of formfields (automaticly)
each field has got the same EntryMacro and ExitMacro (named Got_Focus and
Lost_Focus). When the EntryMacro or ExitMacro - event occurs and for example
the Got_Focus routine is called, how can I determine which FormField has got
the focus (and for the Lost_Focus which FormField lost the focus)?

Thanks Peter

Re: Which formfield has the focus by Jay

Jay
Thu Aug 26 09:08:49 CDT 2004

Peter Lingo wrote:
> Hello,
> in an template which creates various numbers of formfields
> (automaticly) each field has got the same EntryMacro and ExitMacro
> (named Got_Focus and Lost_Focus). When the EntryMacro or ExitMacro -
> event occurs and for example the Got_Focus routine is called, how can
> I determine which FormField has got the focus (and for the Lost_Focus
> which FormField lost the focus)?
>
> Thanks Peter

See http://word.mvps.org/FAQs/TblsFldsFms/GetCurFmFldName.htm.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org



Re: Which formfield has the focus by Peter

Peter
Thu Aug 26 09:17:07 CDT 2004

Hi Peter Lingo

You can use the following code to return the name of the current FormField:

Private Function iwlCurrentFFName() As String
With Selection
If .FormFields.count = 1 Then

' CheckBox or DropDown, with or without a name
iwlCurrentFFName = .FormFields(1).Name

' Only executed if the TextBox has a name
ElseIf .FormFields.count = 0 And .Bookmarks.count > 0 Then
iwlCurrentFFName = .Bookmarks(.Bookmarks.count).Name
End If
End With
End Function

You can use the above function in both the OnEntry and OnExit macros and it will return
the correct FormField Name. Depending upon what you are doing it may in fact be more
useful to return a reference to the current FormField rather than its name.

HTH + Cheers - Peter


"Peter Lingo" <peter.lingo@tiscali.de>, said:

>Hello,
>in an template which creates various numbers of formfields (automaticly)
>each field has got the same EntryMacro and ExitMacro (named Got_Focus and
>Lost_Focus). When the EntryMacro or ExitMacro - event occurs and for example
>the Got_Focus routine is called, how can I determine which FormField has got
>the focus (and for the Lost_Focus which FormField lost the focus)?
>
>Thanks Peter
>


Re: Which formfield has the focus by Peter

Peter
Thu Aug 26 13:48:19 CDT 2004

Thanks for the answer,
the code works fine nearly, but one question to the behaviour of the events.
Why does the ExitMacro is executed only when loosing the focus by the
tab-key. When a form field has the focus and I click into the text with the
mouse there is no ExitMacro - Events invoked.
That's normal?
Thanks Peter


"Jay Freedman" <jay.freedman@verizon.net> schrieb im Newsbeitrag
news:uiB%232Y3iEHA.3456@TK2MSFTNGP12.phx.gbl...
> Peter Lingo wrote:
>> Hello,
>> in an template which creates various numbers of formfields
>> (automaticly) each field has got the same EntryMacro and ExitMacro
>> (named Got_Focus and Lost_Focus). When the EntryMacro or ExitMacro -
>> event occurs and for example the Got_Focus routine is called, how can
>> I determine which FormField has got the focus (and for the Lost_Focus
>> which FormField lost the focus)?
>>
>> Thanks Peter
>
> See http://word.mvps.org/FAQs/TblsFldsFms/GetCurFmFldName.htm.
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ: http://word.mvps.org
>
>



Re: Which formfield has the focus by Jay

Jay
Thu Aug 26 16:33:46 CDT 2004

Sorry, yes, that's normal.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org

Peter Lingo wrote:
> Thanks for the answer,
> the code works fine nearly, but one question to the behaviour of the
> events. Why does the ExitMacro is executed only when loosing the
> focus by the tab-key. When a form field has the focus and I click
> into the text with the mouse there is no ExitMacro - Events invoked.
> That's normal?
> Thanks Peter
>
>
> "Jay Freedman" <jay.freedman@verizon.net> schrieb im Newsbeitrag
> news:uiB%232Y3iEHA.3456@TK2MSFTNGP12.phx.gbl...
>> Peter Lingo wrote:
>>> Hello,
>>> in an template which creates various numbers of formfields
>>> (automaticly) each field has got the same EntryMacro and ExitMacro
>>> (named Got_Focus and Lost_Focus). When the EntryMacro or ExitMacro -
>>> event occurs and for example the Got_Focus routine is called, how
>>> can I determine which FormField has got the focus (and for the
>>> Lost_Focus which FormField lost the focus)?
>>>
>>> Thanks Peter
>>
>> See http://word.mvps.org/FAQs/TblsFldsFms/GetCurFmFldName.htm.
>>
>> --
>> Regards,
>> Jay Freedman
>> Microsoft Word MVP FAQ: http://word.mvps.org



Re: Which formfield has the focus by Peter

Peter
Thu Aug 26 21:49:39 CDT 2004

Hi Peter

No, the OnExit macro should fire however you leave the FormField, i.e.: Tab, Shift+Tab, or
Mouse.

I've just rechecked using Word XP, 2003. I believe this to be consistent with Word 97 and
2000 but I can't double check at this time.

Cheers - Peter

"Jay Freedman" <jay.freedman@verizon.net>, said:

>Sorry, yes, that's normal.

HTH + Cheers - Peter


Re: Which formfield has the focus by Peter

Peter
Fri Aug 27 08:16:44 CDT 2004

Hi Peter,
The OnExit macro is fired if you click with the mouse to the next formfield,
but if you click on a part of the normal text there is no event fired. The
(little) problem is that you can't avoid that the normal user only click
into the formfields. I've checked this with WrdXP and Wrd2000 and found the
same behaviour.

Regards Peter II


"Peter Hewett" <nospam@xtra.co.nz> schrieb im Newsbeitrag
news:718ti0tkcrul81u0ngi0fqko0ml8olnai6@4ax.com...
> Hi Peter
>
> No, the OnExit macro should fire however you leave the FormField, i.e.:
> Tab, Shift+Tab, or
> Mouse.
>
> I've just rechecked using Word XP, 2003. I believe this to be consistent
> with Word 97 and
> 2000 but I can't double check at this time.
>
> Cheers - Peter
>
> "Jay Freedman" <jay.freedman@verizon.net>, said:
>
>>Sorry, yes, that's normal.
>
> HTH + Cheers - Peter
>



Re: Which formfield has the focus by Peter

Peter
Fri Aug 27 09:40:36 CDT 2004

Hi Peter Lingo

Ah, I've got it! You mean you have a document with section breaks and not all of the
sections are protected and when you click in one of the unprotected sections the FormField
you're in does not fire it's OnExit macro.

Yes - yet another one of Words cute idiosyncrasies, makes life a joy what :(

FormField based forms are only robust if they don't contain ActiveX controls and
unprotected sections.

Cheers - Peter


"Peter Lingo" <peter.lingo@tiscali.de>, said:

>Hi Peter,
>The OnExit macro is fired if you click with the mouse to the next formfield,
>but if you click on a part of the normal text there is no event fired. The
>(little) problem is that you can't avoid that the normal user only click
>into the formfields. I've checked this with WrdXP and Wrd2000 and found the
>same behaviour.
>
>Regards Peter II
>
>
>"Peter Hewett" <nospam@xtra.co.nz> schrieb im Newsbeitrag
>news:718ti0tkcrul81u0ngi0fqko0ml8olnai6@4ax.com...
>> Hi Peter
>>
>> No, the OnExit macro should fire however you leave the FormField, i.e.:
>> Tab, Shift+Tab, or
>> Mouse.
>>
>> I've just rechecked using Word XP, 2003. I believe this to be consistent
>> with Word 97 and
>> 2000 but I can't double check at this time.
>>
>> Cheers - Peter
>>
>> "Jay Freedman" <jay.freedman@verizon.net>, said:
>>
>>>Sorry, yes, that's normal.
>>
>> HTH + Cheers - Peter
>>
>

HTH + Cheers - Peter