|
|
Hello,
I am trying to set up a document and I need it to ignore a record with a given criteria. I have used 'Skip If' before however this statement generates lots of error messages within our document generation system and I am trying to avoid that. How does 'Next If' differ from 'Skip If' and can I use more than one 'Next If' statement in a document? I have set the document up with the following:
«Next If {FIELD1} <> 2» «Next If {FIELD2} <> 1» «Next If {FIELD1} <> B»
Do you foresee any problems with that? I am using Windows XP and Word 2000 from Office 2000 Premium
Thanks, Chris
|
|
<<Next if>> has some similar constraints to <<Skip if>>, e.g. you can't use it in certain places such as text boxes.
However, the effect of <<next if>> is quite literal, i.e. if the condition is true, Word will move to the next data source record and continue processing the current "copy" of the Mail Merge Main Document. If the condition is false, Word takes no action. So...
[Quoted Text] > «Next If {FIELD1} <> 2» «Next If {FIELD2} <> 1» «Next If {FIELD1} <> B»
....if you're trying to use that to move 3 records if field1 is "C" and field2 is 50, that should work. But if you're trying to move 1 record if (field1 is not 2) or (field2 is not 1) or (field1 is not B) then you need to put all the conditions inside a single <<Next if>>, which you could do using e.g.
{ NEXTIF { ={ COMPARE { MERGEFIELD FIELD1 } <> 2 }+{ COMPARE { MERGEFIELD FIELD2 } <> 1 }+{ COMPARE { MERGEFIELD FIELD1 } <> "B" } } <> 0 }
(Or something like that...)
Peter Jamieson "Chris Stammers" <ChrisStammers[ at ]discussions.microsoft.com> wrote in message news:892D3082-3233-4487-8C14-72B239685DDB[ at ]microsoft.com... > Hello, > > I am trying to set up a document and I need it to ignore a record with a > given criteria. I have used 'Skip If' before however this statement > generates > lots of error messages within our document generation system and I am > trying > to avoid that. How does 'Next If' differ from 'Skip If' and can I use more > than one 'Next If' statement in a document? I have set the document up > with > the following: > > «Next If {FIELD1} <> 2» «Next If {FIELD2} <> 1» «Next If {FIELD1} <> B» > > Do you foresee any problems with that? I am using Windows XP and Word 2000 > from Office 2000 Premium > > Thanks, > Chris
|
|
Thanks Peter. Apologies if I sound thick here - do I need to manually construct that statement? It's just that it is my understanding that it won't work if you do and the Next If statement doesn't have the facility to expand or add in the way. Or am I totally missing the point?
Thanks. Regards, Chris
"Peter Jamieson" wrote:
[Quoted Text] > <<Next if>> has some similar constraints to <<Skip if>>, e.g. you can't use > it in certain places such as text boxes. > > However, the effect of <<next if>> is quite literal, i.e. if the condition > is true, Word will move to the next data source record and continue > processing the current "copy" of the Mail Merge Main Document. If the > condition is false, Word takes no action. So... > > > «Next If {FIELD1} <> 2» «Next If {FIELD2} <> 1» «Next If {FIELD1} <> B» > > ...if you're trying to use that to move 3 records if field1 is "C" and > field2 is 50, that should work. But if you're trying to move 1 record if > (field1 is not 2) or (field2 is not 1) or (field1 is not B) then you need to > put all the conditions inside a single <<Next if>>, which you could do using > e.g. > > { NEXTIF { ={ COMPARE { MERGEFIELD FIELD1 } <> 2 }+{ COMPARE { MERGEFIELD > FIELD2 } <> 1 }+{ COMPARE { MERGEFIELD FIELD1 } <> "B" } } <> 0 } > > (Or something like that...) > > Peter Jamieson > "Chris Stammers" <ChrisStammers[ at ]discussions.microsoft.com> wrote in message > news:892D3082-3233-4487-8C14-72B239685DDB[ at ]microsoft.com... > > Hello, > > > > I am trying to set up a document and I need it to ignore a record with a > > given criteria. I have used 'Skip If' before however this statement > > generates > > lots of error messages within our document generation system and I am > > trying > > to avoid that. How does 'Next If' differ from 'Skip If' and can I use more > > than one 'Next If' statement in a document? I have set the document up > > with > > the following: > > > > «Next If {FIELD1} <> 2» «Next If {FIELD2} <> 1» «Next If {FIELD1} <> B» > > > > Do you foresee any problems with that? I am using Windows XP and Word 2000 > > from Office 2000 Premium > > > > Thanks, > > Chris >
|
|
|
[Quoted Text] > do I need to manually > construct that statement?
Yes, you basically start with ctrl-F9 to insert each pair of the special field braces {} and type everything else. You could do it in VBA also.
> It's just that it is my understanding that it won't > work if you do
Not sure what you mean here - are you saying that { NEXTIF } fields will only work if you construct them using the Next If dropdown entry?
> and the Next If statement doesn't have the facility to expand > or add in the way.
...or here!
Peter Jamieson
"Chris Stammers" <ChrisStammers[ at ]discussions.microsoft.com> wrote in message news:A0F62129-EE5D-491B-A277-1086FB8856C0[ at ]microsoft.com... > Thanks Peter. Apologies if I sound thick here - do I need to manually > construct that statement? It's just that it is my understanding that it > won't > work if you do and the Next If statement doesn't have the facility to > expand > or add in the way. Or am I totally missing the point? > > Thanks. > Regards, > Chris > > "Peter Jamieson" wrote: > >> <<Next if>> has some similar constraints to <<Skip if>>, e.g. you can't >> use >> it in certain places such as text boxes. >> >> However, the effect of <<next if>> is quite literal, i.e. if the >> condition >> is true, Word will move to the next data source record and continue >> processing the current "copy" of the Mail Merge Main Document. If the >> condition is false, Word takes no action. So... >> >> > «Next If {FIELD1} <> 2» «Next If {FIELD2} <> 1» «Next If {FIELD1} <> B» >> >> ...if you're trying to use that to move 3 records if field1 is "C" and >> field2 is 50, that should work. But if you're trying to move 1 record if >> (field1 is not 2) or (field2 is not 1) or (field1 is not B) then you need >> to >> put all the conditions inside a single <<Next if>>, which you could do >> using >> e.g. >> >> { NEXTIF { ={ COMPARE { MERGEFIELD FIELD1 } <> 2 }+{ COMPARE { MERGEFIELD >> FIELD2 } <> 1 }+{ COMPARE { MERGEFIELD FIELD1 } <> "B" } } <> 0 } >> >> (Or something like that...) >> >> Peter Jamieson >> "Chris Stammers" <ChrisStammers[ at ]discussions.microsoft.com> wrote in >> message >> news:892D3082-3233-4487-8C14-72B239685DDB[ at ]microsoft.com... >> > Hello, >> > >> > I am trying to set up a document and I need it to ignore a record with >> > a >> > given criteria. I have used 'Skip If' before however this statement >> > generates >> > lots of error messages within our document generation system and I am >> > trying >> > to avoid that. How does 'Next If' differ from 'Skip If' and can I use >> > more >> > than one 'Next If' statement in a document? I have set the document up >> > with >> > the following: >> > >> > «Next If {FIELD1} <> 2» «Next If {FIELD2} <> 1» «Next If {FIELD1} <> B» >> > >> > Do you foresee any problems with that? I am using Windows XP and Word >> > 2000 >> > from Office 2000 Premium >> > >> > Thanks, >> > Chris >>
|
|
Got it! Thanks. I'll see how I get on with that.
Regards, Chris
"Peter Jamieson" wrote:
[Quoted Text] > > do I need to manually > > construct that statement? > > Yes, you basically start with ctrl-F9 to insert each pair of the special > field braces {} and type everything else. You could do it in VBA also. > > > It's just that it is my understanding that it won't > > work if you do > > Not sure what you mean here - are you saying that { NEXTIF } fields will > only work if you construct them using the Next If dropdown entry? > > > and the Next If statement doesn't have the facility to expand > > or add in the way. > > ...or here! > > Peter Jamieson > > "Chris Stammers" <ChrisStammers[ at ]discussions.microsoft.com> wrote in message > news:A0F62129-EE5D-491B-A277-1086FB8856C0[ at ]microsoft.com... > > Thanks Peter. Apologies if I sound thick here - do I need to manually > > construct that statement? It's just that it is my understanding that it > > won't > > work if you do and the Next If statement doesn't have the facility to > > expand > > or add in the way. Or am I totally missing the point? > > > > Thanks. > > Regards, > > Chris > > > > "Peter Jamieson" wrote: > > > >> <<Next if>> has some similar constraints to <<Skip if>>, e.g. you can't > >> use > >> it in certain places such as text boxes. > >> > >> However, the effect of <<next if>> is quite literal, i.e. if the > >> condition > >> is true, Word will move to the next data source record and continue > >> processing the current "copy" of the Mail Merge Main Document. If the > >> condition is false, Word takes no action. So... > >> > >> > «Next If {FIELD1} <> 2» «Next If {FIELD2} <> 1» «Next If {FIELD1} <> B» > >> > >> ...if you're trying to use that to move 3 records if field1 is "C" and > >> field2 is 50, that should work. But if you're trying to move 1 record if > >> (field1 is not 2) or (field2 is not 1) or (field1 is not B) then you need > >> to > >> put all the conditions inside a single <<Next if>>, which you could do > >> using > >> e.g. > >> > >> { NEXTIF { ={ COMPARE { MERGEFIELD FIELD1 } <> 2 }+{ COMPARE { MERGEFIELD > >> FIELD2 } <> 1 }+{ COMPARE { MERGEFIELD FIELD1 } <> "B" } } <> 0 } > >> > >> (Or something like that...) > >> > >> Peter Jamieson > >> "Chris Stammers" <ChrisStammers[ at ]discussions.microsoft.com> wrote in > >> message > >> news:892D3082-3233-4487-8C14-72B239685DDB[ at ]microsoft.com... > >> > Hello, > >> > > >> > I am trying to set up a document and I need it to ignore a record with > >> > a > >> > given criteria. I have used 'Skip If' before however this statement > >> > generates > >> > lots of error messages within our document generation system and I am > >> > trying > >> > to avoid that. How does 'Next If' differ from 'Skip If' and can I use > >> > more > >> > than one 'Next If' statement in a document? I have set the document up > >> > with > >> > the following: > >> > > >> > «Next If {FIELD1} <> 2» «Next If {FIELD2} <> 1» «Next If {FIELD1} <> B» > >> > > >> > Do you foresee any problems with that? I am using Windows XP and Word > >> > 2000 > >> > from Office 2000 Premium > >> > > >> > Thanks, > >> > Chris > >> > > >
|
|
One more question - will the NEXTIF function select the next record even if it doesn't meet the criteria? The reason I ask is that when I constructed the string, the document produced however there were records included that shouldn't have been. Also, what is the function of the <> 0 inside the last bracket?
Thanks, Chris
"Peter Jamieson" wrote:
[Quoted Text] > > do I need to manually > > construct that statement? > > Yes, you basically start with ctrl-F9 to insert each pair of the special > field braces {} and type everything else. You could do it in VBA also. > > > It's just that it is my understanding that it won't > > work if you do > > Not sure what you mean here - are you saying that { NEXTIF } fields will > only work if you construct them using the Next If dropdown entry? > > > and the Next If statement doesn't have the facility to expand > > or add in the way. > > ...or here! > > Peter Jamieson > > "Chris Stammers" <ChrisStammers[ at ]discussions.microsoft.com> wrote in message > news:A0F62129-EE5D-491B-A277-1086FB8856C0[ at ]microsoft.com... > > Thanks Peter. Apologies if I sound thick here - do I need to manually > > construct that statement? It's just that it is my understanding that it > > won't > > work if you do and the Next If statement doesn't have the facility to > > expand > > or add in the way. Or am I totally missing the point? > > > > Thanks. > > Regards, > > Chris > > > > "Peter Jamieson" wrote: > > > >> <<Next if>> has some similar constraints to <<Skip if>>, e.g. you can't > >> use > >> it in certain places such as text boxes. > >> > >> However, the effect of <<next if>> is quite literal, i.e. if the > >> condition > >> is true, Word will move to the next data source record and continue > >> processing the current "copy" of the Mail Merge Main Document. If the > >> condition is false, Word takes no action. So... > >> > >> > «Next If {FIELD1} <> 2» «Next If {FIELD2} <> 1» «Next If {FIELD1} <> B» > >> > >> ...if you're trying to use that to move 3 records if field1 is "C" and > >> field2 is 50, that should work. But if you're trying to move 1 record if > >> (field1 is not 2) or (field2 is not 1) or (field1 is not B) then you need > >> to > >> put all the conditions inside a single <<Next if>>, which you could do > >> using > >> e.g. > >> > >> { NEXTIF { ={ COMPARE { MERGEFIELD FIELD1 } <> 2 }+{ COMPARE { MERGEFIELD > >> FIELD2 } <> 1 }+{ COMPARE { MERGEFIELD FIELD1 } <> "B" } } <> 0 } > >> > >> (Or something like that...) > >> > >> Peter Jamieson > >> "Chris Stammers" <ChrisStammers[ at ]discussions.microsoft.com> wrote in > >> message > >> news:892D3082-3233-4487-8C14-72B239685DDB[ at ]microsoft.com... > >> > Hello, > >> > > >> > I am trying to set up a document and I need it to ignore a record with > >> > a > >> > given criteria. I have used 'Skip If' before however this statement > >> > generates > >> > lots of error messages within our document generation system and I am > >> > trying > >> > to avoid that. How does 'Next If' differ from 'Skip If' and can I use > >> > more > >> > than one 'Next If' statement in a document? I have set the document up > >> > with > >> > the following: > >> > > >> > «Next If {FIELD1} <> 2» «Next If {FIELD2} <> 1» «Next If {FIELD1} <> B» > >> > > >> > Do you foresee any problems with that? I am using Windows XP and Word > >> > 2000 > >> > from Office 2000 Premium > >> > > >> > Thanks, > >> > Chris > >> > > >
|
|
|
[Quoted Text] > One more question - will the NEXTIF function select the next record even > if > it doesn't meet the criteria?
Yes. All NEXTIF does is tell Word to move to the next record if the criteria match. Word then processes the remainder of the Mail Merge Main Document starting from that document.
This is wht I meant when I said that "the effect of <<next if>> is quite literal". It doesn't provide a mechanism to filter all records that match the criteria until you get to the next one that does not. In theory, SKIP IF kind of does that, but also has its limitations. In short, there is at least one field missing from the language and it's probably something like { NEXT WHILE }
Typically to exclude all records that meet certain criteria, you need to do it in the data source and/or the query that drives the merge. But that's actually logically different from what a { NEXT WHILE } would give you.
> Also, what is the function of the <> 0 inside the last > bracket?
COMPARE returns 0 if the comparison fails and 1 if the comparison succeeds.
So the { =compare+compare+compare } field returns 0 only if all the comparisons fail. If one or more succeed you get a number between 1 and 3.
So if you want to NEXTIF only if one or more comparisons succeed, you want { =compare+compare+compare } to be non-zero (or > 0, if you want).
Peter Jamieson "Chris Stammers" <ChrisStammers[ at ]discussions.microsoft.com> wrote in message news:ED7821C8-0964-4787-9B4A-044FB2286C0A[ at ]microsoft.com... > One more question - will the NEXTIF function select the next record even > if > it doesn't meet the criteria? The reason I ask is that when I constructed > the > string, the document produced however there were records included that > shouldn't have been. Also, what is the function of the <> 0 inside the > last > bracket? > > Thanks, > Chris > > "Peter Jamieson" wrote: > >> > do I need to manually >> > construct that statement? >> >> Yes, you basically start with ctrl-F9 to insert each pair of the special >> field braces {} and type everything else. You could do it in VBA also. >> >> > It's just that it is my understanding that it won't >> > work if you do >> >> Not sure what you mean here - are you saying that { NEXTIF } fields will >> only work if you construct them using the Next If dropdown entry? >> >> > and the Next If statement doesn't have the facility to expand >> > or add in the way. >> >> ...or here! >> >> Peter Jamieson >> >> "Chris Stammers" <ChrisStammers[ at ]discussions.microsoft.com> wrote in >> message >> news:A0F62129-EE5D-491B-A277-1086FB8856C0[ at ]microsoft.com... >> > Thanks Peter. Apologies if I sound thick here - do I need to manually >> > construct that statement? It's just that it is my understanding that it >> > won't >> > work if you do and the Next If statement doesn't have the facility to >> > expand >> > or add in the way. Or am I totally missing the point? >> > >> > Thanks. >> > Regards, >> > Chris >> > >> > "Peter Jamieson" wrote: >> > >> >> <<Next if>> has some similar constraints to <<Skip if>>, e.g. you >> >> can't >> >> use >> >> it in certain places such as text boxes. >> >> >> >> However, the effect of <<next if>> is quite literal, i.e. if the >> >> condition >> >> is true, Word will move to the next data source record and continue >> >> processing the current "copy" of the Mail Merge Main Document. If the >> >> condition is false, Word takes no action. So... >> >> >> >> > «Next If {FIELD1} <> 2» «Next If {FIELD2} <> 1» «Next If {FIELD1} <> >> >> > B» >> >> >> >> ...if you're trying to use that to move 3 records if field1 is "C" and >> >> field2 is 50, that should work. But if you're trying to move 1 record >> >> if >> >> (field1 is not 2) or (field2 is not 1) or (field1 is not B) then you >> >> need >> >> to >> >> put all the conditions inside a single <<Next if>>, which you could do >> >> using >> >> e.g. >> >> >> >> { NEXTIF { ={ COMPARE { MERGEFIELD FIELD1 } <> 2 }+{ COMPARE { >> >> MERGEFIELD >> >> FIELD2 } <> 1 }+{ COMPARE { MERGEFIELD FIELD1 } <> "B" } } <> 0 } >> >> >> >> (Or something like that...) >> >> >> >> Peter Jamieson >> >> "Chris Stammers" <ChrisStammers[ at ]discussions.microsoft.com> wrote in >> >> message >> >> news:892D3082-3233-4487-8C14-72B239685DDB[ at ]microsoft.com... >> >> > Hello, >> >> > >> >> > I am trying to set up a document and I need it to ignore a record >> >> > with >> >> > a >> >> > given criteria. I have used 'Skip If' before however this statement >> >> > generates >> >> > lots of error messages within our document generation system and I >> >> > am >> >> > trying >> >> > to avoid that. How does 'Next If' differ from 'Skip If' and can I >> >> > use >> >> > more >> >> > than one 'Next If' statement in a document? I have set the document >> >> > up >> >> > with >> >> > the following: >> >> > >> >> > «Next If {FIELD1} <> 2» «Next If {FIELD2} <> 1» «Next If {FIELD1} <> >> >> > B» >> >> > >> >> > Do you foresee any problems with that? I am using Windows XP and >> >> > Word >> >> > 2000 >> >> > from Office 2000 Premium >> >> > >> >> > Thanks, >> >> > Chris >> >> >> >> >>
|
|
Thanks again Peter. I have kept your query string, including the <> 0 at the end, but substituted the NEXTIF for SKIPIF. This seems to have worked fine.
Thanks again for your guidance.
"Peter Jamieson" wrote:
[Quoted Text] > > One more question - will the NEXTIF function select the next record even > > if > > it doesn't meet the criteria? > > Yes. All NEXTIF does is tell Word to move to the next record if the criteria > match. Word then processes the remainder of the Mail Merge Main Document > starting from that document. > > This is wht I meant when I said that "the effect of <<next if>> is quite > literal". It doesn't provide a mechanism to filter all records that match > the criteria until you get to the next one that does not. In theory, SKIP IF > kind of does that, but also has its limitations. In short, there is at least > one field missing from the language and it's probably something like { NEXT > WHILE } > > Typically to exclude all records that meet certain criteria, you need to do > it in the data source and/or the query that drives the merge. But that's > actually logically different from what a { NEXT WHILE } would give you. > > > Also, what is the function of the <> 0 inside the last > > bracket? > > COMPARE returns 0 if the comparison fails and 1 if the comparison succeeds. > > So the { =compare+compare+compare } field returns 0 only if all the > comparisons fail. If one or more succeed you get a number between 1 and 3. > > So if you want to NEXTIF only if one or more comparisons succeed, you want > { =compare+compare+compare } to be non-zero (or > 0, if you want). > > Peter Jamieson > "Chris Stammers" <ChrisStammers[ at ]discussions.microsoft.com> wrote in message > news:ED7821C8-0964-4787-9B4A-044FB2286C0A[ at ]microsoft.com... > > One more question - will the NEXTIF function select the next record even > > if > > it doesn't meet the criteria? The reason I ask is that when I constructed > > the > > string, the document produced however there were records included that > > shouldn't have been. Also, what is the function of the <> 0 inside the > > last > > bracket? > > > > Thanks, > > Chris > > > > "Peter Jamieson" wrote: > > > >> > do I need to manually > >> > construct that statement? > >> > >> Yes, you basically start with ctrl-F9 to insert each pair of the special > >> field braces {} and type everything else. You could do it in VBA also. > >> > >> > It's just that it is my understanding that it won't > >> > work if you do > >> > >> Not sure what you mean here - are you saying that { NEXTIF } fields will > >> only work if you construct them using the Next If dropdown entry? > >> > >> > and the Next If statement doesn't have the facility to expand > >> > or add in the way. > >> > >> ...or here! > >> > >> Peter Jamieson > >> > >> "Chris Stammers" <ChrisStammers[ at ]discussions.microsoft.com> wrote in > >> message > >> news:A0F62129-EE5D-491B-A277-1086FB8856C0[ at ]microsoft.com... > >> > Thanks Peter. Apologies if I sound thick here - do I need to manually > >> > construct that statement? It's just that it is my understanding that it > >> > won't > >> > work if you do and the Next If statement doesn't have the facility to > >> > expand > >> > or add in the way. Or am I totally missing the point? > >> > > >> > Thanks. > >> > Regards, > >> > Chris > >> > > >> > "Peter Jamieson" wrote: > >> > > >> >> <<Next if>> has some similar constraints to <<Skip if>>, e.g. you > >> >> can't > >> >> use > >> >> it in certain places such as text boxes. > >> >> > >> >> However, the effect of <<next if>> is quite literal, i.e. if the > >> >> condition > >> >> is true, Word will move to the next data source record and continue > >> >> processing the current "copy" of the Mail Merge Main Document. If the > >> >> condition is false, Word takes no action. So... > >> >> > >> >> > «Next If {FIELD1} <> 2» «Next If {FIELD2} <> 1» «Next If {FIELD1} <> > >> >> > B» > >> >> > >> >> ...if you're trying to use that to move 3 records if field1 is "C" and > >> >> field2 is 50, that should work. But if you're trying to move 1 record > >> >> if > >> >> (field1 is not 2) or (field2 is not 1) or (field1 is not B) then you > >> >> need > >> >> to > >> >> put all the conditions inside a single <<Next if>>, which you could do > >> >> using > >> >> e.g. > >> >> > >> >> { NEXTIF { ={ COMPARE { MERGEFIELD FIELD1 } <> 2 }+{ COMPARE { > >> >> MERGEFIELD > >> >> FIELD2 } <> 1 }+{ COMPARE { MERGEFIELD FIELD1 } <> "B" } } <> 0 } > >> >> > >> >> (Or something like that...) > >> >> > >> >> Peter Jamieson > >> >> "Chris Stammers" <ChrisStammers[ at ]discussions.microsoft.com> wrote in > >> >> message > >> >> news:892D3082-3233-4487-8C14-72B239685DDB[ at ]microsoft.com... > >> >> > Hello, > >> >> > > >> >> > I am trying to set up a document and I need it to ignore a record > >> >> > with > >> >> > a > >> >> > given criteria. I have used 'Skip If' before however this statement > >> >> > generates > >> >> > lots of error messages within our document generation system and I > >> >> > am > >> >> > trying > >> >> > to avoid that. How does 'Next If' differ from 'Skip If' and can I > >> >> > use > >> >> > more > >> >> > than one 'Next If' statement in a document? I have set the document > >> >> > up > >> >> > with > >> >> > the following: > >> >> > > >> >> > «Next If {FIELD1} <> 2» «Next If {FIELD2} <> 1» «Next If {FIELD1} <> > >> >> > B» > >> >> > > >> >> > Do you foresee any problems with that? I am using Windows XP and > >> >> > Word > >> >> > 2000 > >> >> > from Office 2000 Premium > >> >> > > >> >> > Thanks, > >> >> > Chris > >> >> > >> > >> > >> >
|
|
|