Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-08-2016, 03:36 PM
JennEx JennEx is offline Mergefield Consisting of Concatenated Strings Windows XP Mergefield Consisting of Concatenated Strings Office 2013
Competent Performer
Mergefield Consisting of Concatenated Strings
 
Join Date: May 2010
Posts: 162
JennEx is on a distinguished road
Default Mergefield Consisting of Concatenated Strings

I'm working on a complex rule for a mail merge field ...

If mail merge field 'r1_relchg' is blank (="") then display "", otherwise display 'r1_sru' (h:mmA/P) - 'r1_srl' (h:mmA/P)

An example of the presentation if r1_relchg <> "" might be:

9:00A-9:30P

I am not certain how, if its possible, to concatenate the 'r1_sru', '-'. and 'r1_srl'
Reply With Quote
  #2  
Old 04-08-2016, 05:02 PM
macropod's Avatar
macropod macropod is offline Mergefield Consisting of Concatenated Strings Windows 7 64bit Mergefield Consisting of Concatenated Strings Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

Ordinarily, one would simply use a field coded as:
{IF«r1_relchg» = "" "" "«r1_sru»-«r1_srl»"}

If the «r1_sru» & «r1_srl» mergefields are blank when there's no data, one could instead use a field between them coded as:
«r1_sru»{IF«r1_relchg» = "" "" "-"}«r1_srl»
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 04-08-2016, 05:43 PM
JennEx JennEx is offline Mergefield Consisting of Concatenated Strings Windows XP Mergefield Consisting of Concatenated Strings Office 2013
Competent Performer
Mergefield Consisting of Concatenated Strings
 
Join Date: May 2010
Posts: 162
JennEx is on a distinguished road
Default

Thank you Paul ... I have some tedious time fields to concatenate.
Reply With Quote
  #4  
Old 04-08-2016, 06:19 PM
macropod's Avatar
macropod macropod is offline Mergefield Consisting of Concatenated Strings Windows 7 64bit Mergefield Consisting of Concatenated Strings Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

ah, c'mon, it's not that hard
Attached Files
File Type: docx JennEx.docx (23.0 KB, 9 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 04-08-2016, 06:46 PM
JennEx JennEx is offline Mergefield Consisting of Concatenated Strings Windows XP Mergefield Consisting of Concatenated Strings Office 2013
Competent Performer
Mergefield Consisting of Concatenated Strings
 
Join Date: May 2010
Posts: 162
JennEx is on a distinguished road
Default

Hey Paul ...

This is what I came up ....

I got the same results as you ... and they weren't really the results I was looking for.

With my data, one record with r1_relchg = "REL", I was given the following results with both scripts:

12:00 A-12:00 A

r1_srl = 9:30 AM ... confirmed time value, no other dta in the column, just blank cells.
r1_sru = 10:00 AM ... confirmed time value, no other dta in the column, just blank cells.

Real estate in the cell is tight, so I am also trying to eliminate the space between the number and the AM/PM.
Attached Files
File Type: docx 12.docx (15.7 KB, 7 views)
Reply With Quote
  #6  
Old 04-08-2016, 07:14 PM
macropod's Avatar
macropod macropod is offline Mergefield Consisting of Concatenated Strings Windows 7 64bit Mergefield Consisting of Concatenated Strings Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

So what do you get with just:
{IF{MERGEFIELD r1_relchg}<> "" "{MERGEFIELD r1_srl \@ "h:mm"}-{MERGEFIELD r1_sru \@ "h:mm"}"}
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 04-09-2016, 04:44 AM
JennEx JennEx is offline Mergefield Consisting of Concatenated Strings Windows XP Mergefield Consisting of Concatenated Strings Office 2013
Competent Performer
Mergefield Consisting of Concatenated Strings
 
Join Date: May 2010
Posts: 162
JennEx is on a distinguished road
Default

That worked Paul. It blows my mind that we we were able to concatenate two time strings with simple switches, but to simply use time as itself in a field required a paragraph of formula. (mind you I haven't tried this in the actual report yet ... it may behave quite differently)

How can the A or P for AM or PM be added? I tried the standard method of formatting but it came out looking like this ...

9:30P -10:00P

{IF{MERGEFIELD r1_relchg}<> "" "{MERGEFIELD r1_srl \@ "h:mmA/P"}-{MERGEFIELD r1_sru \@ "h:mmA/P"}"}
Reply With Quote
  #8  
Old 04-09-2016, 05:10 AM
macropod's Avatar
macropod macropod is offline Mergefield Consisting of Concatenated Strings Windows 7 64bit Mergefield Consisting of Concatenated Strings Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

Quote:
Originally Posted by JennEx View Post
That worked Paul. It blows my mind that we we were able to concatenate two time strings with simple switches, but to simply use time as itself in a field required a paragraph of formula. (mind you I haven't tried this in the actual report yet ... it may behave quite differently)
Umm, how about trying it there, then?

Quote:
Originally Posted by JennEx View Post
How can the A or P for AM or PM be added? I tried the standard method of formatting but it came out looking like this ...

9:30P -10:00P
The standard field code for the AM/PM is:

{IF{MERGEFIELD r1_relchg}<> "" "{MERGEFIELD r1_srl \@ "h:mm AM/PM"}-{MERGEFIELD r1_sru \@ "h:mm AM/PM"}"}

but I didn't bother with that because you said:
Quote:
Originally Posted by JennEx View Post
Real estate in the cell is tight, so I am also trying to eliminate the space between the number and the AM/PM.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 04-09-2016, 05:31 AM
JennEx JennEx is offline Mergefield Consisting of Concatenated Strings Windows XP Mergefield Consisting of Concatenated Strings Office 2013
Competent Performer
Mergefield Consisting of Concatenated Strings
 
Join Date: May 2010
Posts: 162
JennEx is on a distinguished road
Default

Turns out the simple method didn't work in the report. All I was able to manage with that was concatenated decimals.

The original (long) way of doing it seems to be working so far, and with it I managed to just retain either the A or P of AM/PM with the time.

I often format my times in Excel as h:mmA/P which leaves me with 8:30A. I just assumed this was possible in Word as well, so that's what I was aiming for.

Thanks Paul!
Reply With Quote
  #10  
Old 04-09-2016, 05:39 AM
macropod's Avatar
macropod macropod is offline Mergefield Consisting of Concatenated Strings Windows 7 64bit Mergefield Consisting of Concatenated Strings Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

Instead of the AM/PM you might consider using a lower-case am/pm, which is a bit narrower or using the std 24-hour time format. You could also reduce in internal cell margin spacing in the affected cells.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 04-09-2016, 06:19 AM
JennEx JennEx is offline Mergefield Consisting of Concatenated Strings Windows XP Mergefield Consisting of Concatenated Strings Office 2013
Competent Performer
Mergefield Consisting of Concatenated Strings
 
Join Date: May 2010
Posts: 162
JennEx is on a distinguished road
Default

Great ideas! I'm going to combine a couple to achieve what I'm looking for.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mergefield Consisting of Concatenated Strings Printing selected pages based on a MERGEFIELD.g. If MERGEFIELD=x then print pages 1,2,4 if MERGEFIEL Richard.p Word 3 04-21-2015 01:14 AM
Save merged document as concatenated merge field values texas791 Word VBA 4 02-25-2014 07:35 PM
Mergefield Consisting of Concatenated Strings Search with multiple strings silverspr Excel 7 03-03-2013 04:45 PM
Concatenated data in subsequent rows doorsgirl Excel 4 09-15-2011 10:37 PM
Mergefield Consisting of Concatenated Strings update style of all strings available between two specific strings vikrantkale Word 1 03-28-2011 06:13 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:53 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft