A Microsoft Word forum. Microsoft Office Word Forum - WordBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Microsoft Office Word Forum - WordBanter forum » Microsoft Word Newsgroups » Mailmerge
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Calculations with possible null value fields



 
 
Thread Tools Display Modes
  #1  
Old February 7th 13, 02:45 PM
JR042 JR042 is offline
Junior Member
 
First recorded activity by WordBanter: Feb 2013
Posts: 1
Default Calculations with possible null value fields

I'm trying to perform the following calculation in Word 2007 mailmerge, using a txt file (with line return record delimiters and vertical bar | field delimiters) as my data source but I keep getting a syntax error if any of the fields have null values:
R1 + C1 + M1

I can use IF statements to test which fields have null values first, and then only perform the relevant calculation on those that don't have null values but when the number of fields in the calculation is higher than two, the number of permutations gets a bit too complex. I may have to do this for a calculation involving 12 fields so I'd rather avoid this kind of logic:

If R1 AND C1 AND M1 = null, total = 0
Else, If R1 AND C1 = null, total = M1
Else, If R1 AND M1 = null, total = C1
Else, If R1 = null, total = C1 + M1
Else, If C1 AND M1 = null, total = R1
Else, If C1 = null, total = R1 + M1
Else, If M1 = null, total = R1 + C1
Else, total = R1 + C1 + M1

If I use Excel as the data source, somehow Word seems to assume null = 0 and the calculation works without IFs, but I have no choice but to use a txt file (there are more than 255 fields, which I believe is the max you can have in Excel - there may be other reasons for using txt which I don't know as I'm not responsible for it and would have difficulty having this changed). I can't manipulate the data source myself but I am looking at having the null values changed to zeros, if possible.

Failing that, is there a simpler way to do this? I've tried to simplify the above by showing only the logic, rather than the actual code, but I'm quite new to programming so if there is a better solution, please could you show the full code?

Thanks!
Ads
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Null values in word 2003 calculations Lenny Tables 0 September 10th 09 07:33 PM
Calculations in text form fields kmewing Microsoft Word Help 8 February 4th 09 05:06 AM
Calculations in Form Fields not working Jeff Doby Microsoft Word Help 2 March 28th 08 07:10 PM
Help! Form fields in table and calculations! R.P.McMurphy Microsoft Word Help 6 December 19th 05 12:38 PM
Calculations in form fields KathyHL Microsoft Word Help 1 June 18th 05 01:46 PM


All times are GMT +1. The time now is 06:47 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright 2004-2020 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.