Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Word - Merge - Crosstab

Status
Not open for further replies.

rayna

Programmer
Sep 24, 2001
54
0
0
CA
I work on MS Word Merge docs (usually XP). They are designed based on a query of a SQL database and the query brings back rows containing the following three pieces of data - Date/Category/Number. I am able to do a table like thus:

Date Sale Type Number of Sales
Aug 7 Chocolate 7
Aug 7 Ice cream 11
Aug 8 Chocolate 4
Aug 8 Soda 9
Aug 8 Ice Cream 13

Etc....

Does anyone know how to build this as a cross tab (in Word) using the same data?

IE...

Aug 7 Aug 8
Chocolate 7 4
Soda 9
Ice Cream 11 13

I have several clients screaming for it this way as it is neater, and until now have only been able to do it the other way.

Any and all help is appreciated.

Thanks!
Rayna

Man plans. God laughs.
 



Hi,

Wow! A query in Word. I do lots of queries in Excel using native spreadsheet functionality (no VBA code). Never thot of using Word.

How do you do that in Word with out VBA?

If I knew how you did it, I may be able to answer your question.

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
OK...here was my developer's response to the question "How is this done without VBA?":

"Build the query directly in C++ and use the Visual Studio wrappers to call open Word, call the query, and pass the result set"

Does that help at all?

Man plans. God laughs.
 


Well, then your developer ought to be able to answer the question you posted.

This forum is for MS Office questions. Obviously, your developer's approch is a programmed solution, "directly in C++," outside the bounds of this forum.

VB, C, C+, C#, pearl, java are all programmed solutions, So my question could be restated thusly...

"How do you do that in Word with out a coded solution?

The question stands.


Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Hi Skip...

Sorry if I am outside the bounds of this forum. I understand that there is extraneous programming going on. But I mistakenly thought my questions was simply a formatting issue - ie how the data was coming into the document was irrelevant. I thought that the data could simply be *displayed* as a cross tab and didn't think it had to be brought in this way.

My apologies.

Rayna

Man plans. God laughs.
 



I have never seen a WORD DOCUMENT used in this way. W

hy would you want to?

There are absolutly no tools at all in WORD to assist in the task. It's like trying to use a screwdriver to hammer a nail. Its the wrong tool for the task.

Why not use Excel? It would be a piece of cake!

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
You know....I think this could be done with Word. I don't see why it could not be. You say the merge brings in the data in "rows". Can you describe more?


Date Sale Type Number of Sales

Are these merge fields in the document?

Can you post how the merge fields are actually laid out in the document?

Gerry
My paintings and sculpture
 
Maybe I'm missing something, but doesn't your end result depend on where you place the merge fields in the Word document? Simply place your fields in columns instead of rows, or vice versa.
 

Word doesn't manipulate merge data, it just formats it, processing a row at a time without any understanding. You must manipulate your data first in order to present the rows you want in the order you want.

Either the Query must be changed or another one on the Result Set added. Although, in theory it should be possible to do in VBA in Word but it makes absolutely no sense to do it that way. It shouldn't be a big job to make the driving process do it - it doesn't matter whether it's a C++ program or anything else - as it already knows all about the data.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

Professional Office Developers Association
 
Although, in theory it should be possible to do in VBA in Word but it makes absolutely no sense to do it that way.
I guess that was what I was trying to say. I agree that it is possible to do this in Word, but it is certainly not something that Word{/b] itself does. It would be VBA, and as Tony says, it would be better to have the driving process do it.

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top