FieldGetText for Numbers

I need to check the number field value on the postOpen event of the document. How do I do that? For Text fields i use this:

OldVendorName = source.FieldGetText(“VendorName”)

Subject: FieldGetText for Numbers

What do you need to check?

taking a guess…try this:

NumValStr = Source.FieldGetText(“NumberField”)

if isNumeric(NumValStr) then

NumVal = cdbl(NumValStr)

else

Msgbox “You have to enter something in the Numberfield field”

end if

Again, that is a guess. I read another response, and they figured you needed to make sure there was something in the field, but that is usually (in my experience) done on a querysave or something, not usually on a postopen. I think you are wanting to check this field for some other reason that simple validation to prevent an empty field.

Hope this helps.

Subject: FieldGetText for Numbers

IML,

Use the back end classes. Starting with the PostOpen event you have access to the back end document even if the document is new. (If the document is not new you can use the back end even earlier, in the QueryOpen event.) The back end is a MUCH cleaner way of examining the values in a document, paricularly if you need to read multivalue fields.

dim v as variant

dim doc as notesdocument

dim item as notesitem

dim thenumber as Double

set doc = Source.document

set item = doc.getfirstitem(“SomeNumberfield”)

v = item.values ’ an array of Doubles if there is a number in there

if isnumeric(v(0)) then

’ do something with this number

thenumber = v(0)

else

’ field is blank

end if

If the document is open in edit mode and you need to read the values of non-rich text fields, call notesuidocument.refresh before examining the back end.

You can also use the back end to change field values. For example if you have a multivalue field “Foo” and you need to select the values “Roy”,“Gee” and “Biv”, you can do this

call uidoc.fieldsettext(“Foo”,“Roy” & chr$(13)&chr$(10) & “Gee” & chr$(13) & chr$(10) & “Biv”)

or this

redim v(2) as string

v(0) = “Roy”

v(1) = “Gee”

v(2) = “Biv”

call uidoc.document.replaceitemvalue(“Foo”,v)

Subject: FieldGetText for Numbers

OldVendorNumber = source.FieldGetText(“VendorNumber”)if OldVendorNumber <>“” then

oldVendorNum = cint(OldVendorNumber)

else

oldVendorNum = 0

end if

Subject: FieldGetText for Numbers

It may help to understand that at the uidoc point, all editable fields are still text. Only at the back end does it take on a datatype, when the front end uidoc is saved.

Subject: RE: FieldGetText for Numbers

And you can easily use the backend access instead of UI classes in PostOpen.