TabOrder after field validation

S

Simon Ransom

I am trying to use a tab order macro to move between form fields but with
validation in some cases to check that a value has in fact been updated. I
am receiving the following VB error dialogue when moving out of the fCurrency
field "This Command is not available because no document is open"... this
appears after the MsgBox has been shown... fCurrency and fPaymentTerms are
DropDown List form fields
=================
Sub TabOrder()

Dim StrCurFFld As String, StrFFldToGoTo As String

If Selection.FormFields.Count = 1 Then
StrCurFFld = Selection.FormFields(1).Name
ElseIf Selection.FormFields.Count = 0 And Selection.Bookmarks.Count > 0 Then
StrCurFFld = Selection.Bookmarks(Selection.Bookmarks.Count).Name
End If

Select Case StrCurFFld

Case "fShippingContactTel"
StrFFldToGoTo = "fOurRef"
Case "fOurRef"
StrFFldToGoTo = "fYourRef"
Case "fYourRef"
StrFFldToGoTo = "fCurrency"
MsgBox "The order total will be displayed automatically once you
have completed this form in full"
Case "fCurrency"
If FormFields("fCurrency").Result = "Currency" Then
MsgBox "Please select the currency from the dropdown list."
StrFFldToGoTo = "fCurrency"
Else
StrFFldToGoTo = "fPaymentTerms"
End If
Case "fPaymentTerms"
If FormFields("fPaymentTerms").Result = "SPECIAL TERMS as below" Then
StrFFldToGoTo = "fSpecialTerms"
Else
StrFFldToGoTo = "fDeliveryTime"
End If
Case "fSpecialTerms"
StrFFldToGoTo = "fDeliveryTime"
Case "fDeliveryTime"
StrFFldToGoTo = "fContractTerms"
End Select

ActiveDocument.Bookmarks(StrFFldToGoTo).Range.Fields(1).Result.Select

End Sub
=================
This is driving me nuts so any input will be most appreciated...

Simon
 
P

Peter Hewett

Hi Simon Ransom

I'd try setting a breakpoint in your code and stepping through it to see where it's
failing.

Presumably (you don't say) you TabOrder procedure is your OnExit macro?

Also, you're code wont work :( You can't stop Word from exiting a FormField using an
OnExit macro. The best you can do is force it to go back to the desired FormField by
using an OnEntry macro. But in turn that means you have to set up OnEntry macros for ALL
FormFields as you cant guarantee that the user will always go to the very next FormField.
If they use Shift+Tab or click on another FormField with the mouse, then they'll end up at
different FormField.

HTH + Cheers - Peter
 

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