Type Mismatch?

I get type mismatch when validating fields

The field is “EventNPDContribution”. It is a number field, in the currency format - 2 decimal places.

May code is as follows :-

If doc.EventNPDContribution(0) = “” Or doc.EventNPDContribution(0) = 0 Then

	Msgbox "You must enter a value in NPD Contibution.", 16, "Field Contains No Value"

	uidoc.EditMode = True

Exit Sub

End If

We don’t user to leave the field empty or put a zero in the field.

any ideas on the above code ?

many thanks in advance

Stefan

Subject: Type Mismatch ??

Any reason you can’t just put an input validation on the field along the lines of

@If(EventNPDContribution = “” |EventNPDContribution = 0; @Failure(“You must enter a value in NPD Contibution”);@Success)

Input validations run on document refresh.

Subject: RE: Type Mismatch ??

Thanks for your reply. This code is set-up in an agent as it is only check when it is submitted to a particular group within the business. It does not get check as the user may not submit the document straight away…

Subject: RE: Type Mismatch ??

Convert the value to string when checking null value, as it is a number field.

cstr(doc.EventNPDContribution(0)) = “” Or

Cint(Round(doc.EventNPDContribution(0),1))

Subject: RE: Type Mismatch ??

I tried that but it does not like the code ???

Subject: RE: Type Mismatch ??

Please see my above posting again and try that. I rectified an error in my earlier posting.

This time, I guess you will not have any problem.

Subject: Type Mismatch ??

Break it out:

If doc.EventNPDContribution(0) = “” then

msgbox “You must enter a value in NPD Contribution.”, 16, “Field Contains No Value”

exit sub

end if

If doc.EventNPDContribution(0) = 0 then

msgbox “You must enter a value in NPD Contribution.”, 16, “Field Contains No Value”

exit sub

end if

I tried this and it appeared to work.

  • Matt