View Single Post
 
Old 04-07-2013, 04:37 PM
macropod's Avatar
macropod macropod is online now Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Jennex,
Quote:
not needing seconds in my field, can I get away with simply removing the references to the seconds?
You could probably reduce the field code to:
{QUOTE
{SET ss{=ROUND({MERGEFIELD Time}*86400,0) \# 0}}
{SET hr{=INT(ss/3600)}}
{SET mn{=INT((ss-hr*3600)/60)}}
{QUOTE"{=IF(hr=0,12,hr)}:{mn}" \@ "h:mm "}{IF{=hr}< 12 a.m. p.m.}}

FWIW, the macro in the link you referred to is one I wrote.
Quote:
what would I have to do to the SQL statement code to allow different recipients. (type and SubResp)
I'm not sure what you're driving at there. If you want to filter the output, so only a predefined set of records is generated, you have two options:
1. Insert a SKIPIF field into the mailmerge main document, so the unwanted records are filtered out; or
2. Modify the SQL statement.
The former is easier for end-users to work with and could be coded like:
{SKIPIF{MERGEFIELD CONTRACT}<> {FILLIN "Contract to include." \o}}
or:
{SKIPIF{MERGEFIELD CONTRACT}= {FILLIN "Contract to exclude." \o}}
or even:
{SKIPIF{IF{FILLIN "Contract to include/exclude." \o }={MERGEFIELD CONTRACT} 0 1}= {FILLIN "1: include. 0: exclude." \o}}
If you'd prefer to do the filtering via the SQL, though, you'd need to hand-code that part, along the lines of the 'where 'Type$'='FR' And 'SubResp'='WPL1' ' in the code in your post. The 'ORDER BY' portion is simply the SQL equivalent of the sort order you'd apply in Word, though even this isn't needed if the data are sorted that way in the data source.

Regarding your remaining issues:
1. You can overcome the header mergefield issue via the use of SET fields in the body and REF fields in the header. See attached (I've made a variety of changes to the header and the first row of the table in the body). I haven't included the field code for the time manipulations as the document works fine for me without it.
2. Try the attached document - if it works, this ceases to be an issue; if not, we can come back to it.
3. Does the SKIPIF approach above (but with your 'Type' or 'SubResp') do as you need? If you need to be able to use both, I can code a field for that, too.
Attached Files
File Type: docx DR-HPL8.docx (380.4 KB, 14 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote