Merge Several Names on One Doc Page, Then Different Names on Next

T

TechScribe

I want to print team rosters in an existing MS Word document, each team
appearing on its own copy of the document. The number of team members varies
from team to team.

Access contains several hundred names in the Employees table. The employees
are members of 57 teams, each employee being on only one team.

A second table contains the names and descriptions of the teams.

The query in Access combines both tables in one record for each employee. To
clarify, I mean that each record contains one employee name, the name of the
team, and the team information. (I agree that successive records contain
duplicate information, but I have not normalized the employee table, so it
remains simple for the users.)

If I could trap the team name in a temporary user-defined variable, the
solution would be elegantly simple: <<Next Record>><<IF team name is same
THEN MemberName>>

I have not found such a user variable in MS Word documentation. I am hoping
that I do not have to resort to macros. I am comfortable with VBA for Access,
but have not done anything like that with MS Word.

To complicate things a bit, I would like to add this document to a master
document that contains two more sub-documents that need the same treatment,
printing employee names by team. The master document would print a bundle of
documents for each team.

If you are curious, the documents in the bundle represent milestones in a
large project that requires tracking. Right now, the team leaders manually
fill in each document. I am trying to simplify their life and improve
accuracy.

Thank you for your valuable time.
 
D

Doug Robbins - Word MVP

See the "Group Multiple items for a single condition" item on fellow MVP
Cindy Meister's website at

http://homepage.swissonline.ch/cindymeister/mergfaq1.htm#DBPic


Or take a look at the following Knowledge Base Article

http://support.microsoft.com/default.aspx?scid=kb;en-us;211303

Or, maybe the following will show you how to do what you are after:

http://cornell.veplan.net/article.aspx?&a=3815


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
P

Peter Jamieson

Doug's covered the "one-many" ground but in this point...

<<
To complicate things a bit, I would like to add this document to a master
document that contains two more sub-documents that need the same treatment,
printing employee names by team. The master document would print a bundle of
documents for each team.
....you may be able to get a Master document approach to work, and it may
work well if you want to impose aand maintain a completely standard style
and layout, but if you want flexibility and maintainability of the system as
a whole it would probably be better to use separate documents and a macro to
process them in turn to produce the bundle you want.

Peter Jamieson
 
T

TechScribe

That worked wonderfully, Doug. Specifically, the SET BOOKMARK did what I
wanted. I looked at SET BOOKMARK previously, but thought it pointed to a
location. I did not realize it could serve as a local variable.

I still have a related problem, though, at the beginning of the next page --
or is it at the end of the current page?

I sort the Employees table by team name, in a manner similar to the examples
you sent me to read.

I SET teamName to the first team name.

Using IF ... THEN ... ELSE, I test a member's team against teamName,
printing the member's name if the team names match.

Then using NEXTIF, I again test the member's team against teamName, getting
the next record if they match.

If the member's team name does not match teamName, that indicates the end of
the current team, it does not get another record, and at the end of the
document, MS Word starts another document page.

That means that the last record fetched contains the first member of the
next team.

HERE IS THE PROBLEM: MS Word seems to fetch another record automatically
when it starts a new page. As a result, I loose the record of the first
member of the next team.

QUESTION: How do I either suppress the automatic next-record fetch, or cause
the record pointer to back up one record?

Thank you for your time.

TechScribe
 
D

Doug Robbins - Word MVP

What do you have as the ELSE result?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
T

TechScribe

Aha! Your question really bugged me. I think I know a solution now.

At the end of the page, I can save the non-team member's name with SET
BOOKMARK and use that at the beginning of the next page.

At the top of the first page I can test for record sequence number being "1"
in the IF ... THEN ... ELSE and print the first member of the first team in
the THEN part. If the sequence number is not "1", it tells me that I am not
on the first page, therefore I can print the contents of the BOOKMARK in the
ELSE part.

I need to be careful about how I do the first NEXTIF at the top of the next
page.

You're a genius, Doug.

Thanks.

[Ummm ... izzat the right solution?]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top