Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I am writing a macro and I am trying to check to make sure the value exists in the field and if it does not I would like to write an error to my log file. I have tried declaring a variable and hoping that it would return True if it was able to be selected and False if not, but if my value exists it is selected and my variable returns False. My code is:
checkValue = Document.Fields(Attr1).Select(Attr2)
if checkValue is true then
....
Else
lg.WriteLine("Command could not be done because the value does not exist in the field.
Thanks
checkValue =ActiveDocument.Evaluate("count({$<Field={'Value'}>} Field)")
If checkValue>0, value exists
Hi,
Tried to use your statement but it doesnt work for me.
if my field name is f and the value is v, what should this statement look like?
checkValue =ActiveDocument.Evaluate("count({$<Field={'Value'}>} Field)")
Thanks.
It will be
checkValue =ActiveDocument.Evaluate("count({$<f={'v'}>} f)")
This works great! Here's a snippit of what I'm doing in C#.
string countString = @"COUNT(DISTINCT{$<[" + fieldName + @"]={'" + value + @"'}>}[" + fieldName + @"])";
if (Int32.Parse(ReportControl.QVDoc.Evaluate(countString)) == 1)
{
//whatever
}