hcl-bot
February 22, 2007, 9:39am
1
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
hcl-bot
February 22, 2007, 9:40am
2
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.
hcl-bot
February 22, 2007, 9:51am
3
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…
hcl-bot
February 22, 2007, 10:07am
4
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))
hcl-bot
February 22, 2007, 10:34am
5
Subject: RE: Type Mismatch ??
I tried that but it does not like the code ???
hcl-bot
February 22, 2007, 1:42pm
6
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.
hcl-bot
February 22, 2007, 10:57am
7
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.