Selecting a Formfield, but it's not getting focus???

J

jjfeenix

I have a table cell containing 2 Option Buttons controls, 1 labeled "Yes",
the other "No". When "Yes" is selected, I use the following code in the Click
event to selects a Text formfield, so that user can start typing:

Dim FrmFldName As String
FrmFldName = "Date" & WhichOptionYes
tableDocument.FormFields(FrmFldName).Select

Even though the default text for the form field is highlight, typing doesn't
do anything, it looks like the focus is still being retained by the "Yes"
button (Dotted lines are visible around it). I have to click in the formfield
or tab/shift tab to it, for typing.

Any suggests?

Thanks.
 
D

Doug Robbins - Word MVP

Try

tableDocument.FormFields(FrmFldName).Range.Select

or

tableDocument.FormFields(FrmFldName).Result = InputBox("Enter the Text for "
& FrmFldName)

--
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
 
J

jjfeenix

Doug:

Thanks for the help, however the
tableDocument.FormFields(FrmFldName).Range.Select

didn't quite work. Something was still eating the very first key pressed.
For example: "August" ended up as "ugust".

After playing with it, I ended up doing a little two-step with the cursor
using this code:

Set myDateCell = .Cells(15)
myDateCell.Select
With Selection
.Collapse Direction:=wdCollapseStart
.MoveEnd Unit:=wdCharacter, Count:=1
End With
End With

tableDocument.FormFields(FrmFldName).Select

Works fine now.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top