PDA

View Full Version : Solved: Do This Unless.....



petedw
06-01-2005, 02:34 AM
Hi,
I have the set up the following VBA Code;

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

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?: pray2:

Many Thanks
Pete

TonyJollans
06-01-2005, 04:13 AM
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.

MOS MASTER
06-01-2005, 09:48 AM
Hi, :yes

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! :whistle: