View Single Post
 
Old 03-19-2020, 02:58 PM
geepxz geepxz is offline Windows 10 Office 2019
Novice
 
Join Date: Mar 2020
Posts: 2
geepxz is on a distinguished road
Default

Youre absolutely right. We divided the USA in 2 for 50 states using USA and U.S.A.


Thank you! ill try this right away and get back to you with feedback!

Quote:
Originally Posted by macropod View Post
I'm not sure that formfield dropdowns will work in this case, as they only accept a maximum of 25 entries and there are more than twice that US States.

As for the tax calculation, with formfields no VBA code is required - it can all be done with field coding. Such a field might be coded along the lines of:
{={IF{REF ddCountr}= "CA" {IF{REF ddRegion}= "ON" 1.13 1.05} 0}*{Half_Fees} \# $,0.00}

Regardless, given the limitation of 25 for formfield dropdown entries, you should instead consider the use of content control dropdowns, for which all your US States can be added. In that case, the VBA code might look like:
Code:
Dim Admin As Single, Tax As Single
With ActiveDocument
  If .SelectContentControlsByTitle("Country")(1) = "US" Then
    Tax = 0
  Else
    If .SelectContentControlsByTitle("Region")(1) = "ON" Then
      Tax = 1.13
    Else
      Tax = 1.05
    End If
  End If
  Admin = .SelectContentControlsByTitle("Admin")(1).Range.Text
  With .SelectContentControlsByTitle("Tax")(1)
    .LockContents = False
    .Range.Text = Format(Tax * Admin, "#,##0.00")
    .LockContents = True
  End With
End With
Note: You shouldn't use content controls and formfields in the same document, as they weren't designed to be used that way and trying to do so can cause problems.
Reply With Quote