Consulting

Results 1 to 3 of 3

Thread: Solved: Do This Unless.....

  1. #1
    VBAX Regular
    Joined
    Apr 2005
    Posts
    86
    Location

    Solved: Do This Unless.....

    Hi,
    I have the set up the following VBA Code;

    [VBA] Public Sub Pence()
    Dim strStatus As String
    strStatus = ActiveDocument.FormFields("pence3").Result
    If strStatus = "0.00" Then
    ActiveDocument.FormFields("dualcharge1").Result = "0.00"
    Else
    ActiveDocument.FormFields("dualcharge1").Result = ""
    End If
    End Sub [/VBA]

    This works fine but i need a little extra adding. I need the Else command to do exactly what it says UNLESS ActiveDocument.FormFields("dualcharge1") already has a value. Is there a way of doing this?

    Many Thanks
    Pete

  2. #2
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Hi Pete,

    UNLESS ActiveDocument.FormFields("dualcharge1") already has a value

    .. means the same as ..

    IF ActiveDocument.FormFields("dualcharge1") doesn't already have a value

    .. which translates to ..

    IF ActiveDocument.FormFields("dualcharge1") = ""

    .. so you want to say ..

    IF ActiveDocument.FormFields("dualcharge1") = "" THEN ActiveDocument.FormFields("dualcharge1") = ""

    Seems pointless! If I've missed something, tell me - otherwise just drop the else altogether.
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi,

    Seams (don't know for sure) you want to have formfields with number values in them?

    If so you can set the correct field format in the properties of the formfield (Double click on it)

    If you want a field that will calculate a value you can set the fieldtype to calculate and check "Calculate on exit" in the properties.

    That way it will update the field (formula) on exit.

    Enjoy!
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

Posting Permissions

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