![]() |
#1
|
|||
|
|||
![]()
Hi all first post from a no techie so please be gentle... Attached excel sheet and word document.
The excel sheet is in two halves, the green columns form the table at the top of the word doc. I want to pull into the word doc table any record that doesn't say NAD.. The second half of the excel sheet columns in purple is the rest of the info for the work sheets that follow on the word doc. Each record needs a sheet completed as per page 2 of the MM. I can get the mail merge to create the sample sheets one for each record, but I cant get the table on page one completed. I need this table to have all the records except those that say NAD. Can anyone help? Sorry if I'm being confusing or if there is a far more obvious/easy way of doing this! Thanks |
#2
|
||||
|
||||
![]()
A mailmerge can't conditionally build a multi-row table this way. It can at best generate multiple one-row tables that you could consolidate post-merge. However, a DATABASE field can generate such a table. That said, it's not clear how this relates to the table on your second page, since a mailmerge typically generates one report per record but you seem to want all records on the first page.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
Thank you. I need the tables on page 2 for all records so this works. The table in page 1 only includes some of the records, I.e all except those with the identification NAD. So yes I'll try the DATABASE field - where can I find out how to do this, googling create database field has not helped! Is there a idiots guide somewhere? Thank you
|
#4
|
||||
|
||||
![]()
For an example of DATABASE field usage, see: https://www.msofficeforums.com/mail-...html#post67110
Be warned, this isn't for those who don't understand the intricacies of SQL. Besides which, you would also need to encompass the field in an IF test to ensure it only generates its output when the merge executes - not when each record is processed.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
![]()
Hi several
![]() I've also managed to make some code and pull the info through from the spreadsheet into the word doc tables (hurrah!) BUT... now if I make an update to the information in the excel sheet, the table wont update and I get an error message... This is the code I'm using below... Any help on what I'm dong wrong. Again sorry if this is obvious, but I've never even heard of SQL code before so am on a rather steep learning curve! Thanks {DATABASE \d "W:\\XXXXX\\XXXXX\\Trial MM data RH.xlsx" \c "Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=W:\\XXXX\\XXXXX\\Trial MM data RH.xlsx;Mode=Read;Extended Properties=\"HDR=YES;IMEX=1;\";Jet OLEDB:System database=\"\";Jet OLEDB:Registry Path=\"\";Jet OLEDB:Engine Type=37;Jet OLEDB ![]() ![]() |
#6
|
||||
|
||||
![]()
If you're using Excel, you shouldn't need the connection string, as the link I pointed you to shows. Assuming the field works when first created, I can't see why it wouldn't also update when refreshed after the Excel data changes. Also, what is the error message? It's a bit hard to diagnose without the error message. That said, based on the workbook attached to your first post, you should be able to use something like:
Code:
{DATABASE \d "W:\\XXXXX\\XXXXX\\Trial MM data RH.xlsx" \s "SELECT `Building`, `Floor`, `Room/Area` FROM `Sheet1$` WHERE `Extent of damage score` = 0 ORDER BY `Sample`" \l "23" \b "191" \h} Code:
{DATABASE \d "{FILENAME \p}/../Trial MM data RH.xlsx" \s "SELECT [Building], [Floor], [Room/Area] FROM [Sheet1$] WHERE [Extent of damage score] = 0 ORDER BY [Sample]" \l "23" \b "191" \h} Note that it doesn't really matter whether you delineate the fields with `` or [].
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Using Mail Merge to create summary report in ONE document | ChandaS | Mail Merge | 1 | 12-19-2014 10:16 PM |
![]() |
esherwood | Mail Merge | 1 | 07-21-2014 09:55 PM |
![]() |
elisa2013 | Mail Merge | 5 | 03-14-2014 02:35 AM |
![]() |
risnasmhd | Mail Merge | 1 | 09-29-2013 08:11 PM |
![]() |
flackend | Mail Merge | 2 | 08-24-2011 11:49 AM |