MS Office Forum / Word / Mailmerge and Fax / June 2006
Merging/database management
|
|
Thread rating:  |
Anthony J. B. - 27 May 2006 02:29 GMT I have created an excel database, which includes 1 column with various numbers representings comments that were made. Each records has an entry in this column which is either a single digit number, or a combination of single digit numbers, separated by a comma, ie., 1 / 1,2,3 / 1,4,2.
From word what I am trying to do is filter the records out from excell so that only the records containing, for example, 2, either in combination with other numbers, or singularly, only those records will merge with excell. I have been trying to do this using the "Insert Word Field" option as sort of a filter, but it is not working. I'm not sure which one I probably should use, if there is one. I have also tried using the "merge query to filter" but that doesn't seem to work. Both options give me the records containing the singluar 1, but it doesn't pull them out of a group.
Help
Graham Mayor - 27 May 2006 06:15 GMT You'll make things much simpler for yourself if you create separate columns for each comment number.
 Signature <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP
My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> I have created an excel database, which includes 1 column with various > numbers representings comments that were made. Each records has an [quoted text clipped - 13 lines] > > Help Anthony J. B. - 29 May 2006 17:38 GMT That would have been my preference too, however, I got this database, and short of re-inputting it, can you think of a way around this?
> You'll make things much simpler for yourself if you create separate columns > for each comment number. [quoted text clipped - 16 lines] > > > > Help Doug Robbins - Word MVP - 29 May 2006 18:03 GMT Still much easier to do it in the data source. You should not need to re-enter everything that is already there.
 Signature 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
> That would have been my preference too, however, I got this database, and > short of re-inputting it, can you think of a way around this? [quoted text clipped - 20 lines] >> > >> > Help Peter Jamieson - 29 May 2006 18:07 GMT Have you tried a. use Tools|Customize to enable the mailmerge toolbar (I'm assuming you're using Word 2002/3) b. click Mail Merge Recipients (3rd icon on the toolbar) c. click on the drop-down in the header of the column you want to filter - let's say the field is called "myfield" d. select "(Advanced...)", the Filter Records e. select myfield in the drop-down list of fields f. select Contains in the "Comparison" g. select the number you want to compare with for the current merge in "Compare To"
Your message suggests that you may have tried that, but please confirm/deny etc.
Here, that results in an SQL query along the following lines
SELECT * FROM `Sheet1$` WHERE `myfield` LIKE '%1%'
and the filter does appear to work.
(if that doesn't mean anything to you, I'll explain)
Peter Jamieson
> That would have been my preference too, however, I got this database, and > short of re-inputting it, can you think of a way around this? [quoted text clipped - 20 lines] >> > >> > Help Anthony J. B. - 31 May 2006 17:49 GMT Thank you for this. I'm using Word 2000, so you know of anyway using this version that I can get it to work. The database file is in Excel 2000 as well. Can I filter it through there better do you think?
Awesome answers from everyone. Thank you so much.
> Have you tried > a. use Tools|Customize to enable the mailmerge toolbar (I'm assuming you're [quoted text clipped - 45 lines] > >> > > >> > Help Peter Jamieson - 01 Jun 2006 11:31 GMT Unfortunately, the "Contains" option does not exist in Word 2000 as you probably discovered, so to do the same thing you would have to issue the SQL using VBA and an OpenDataSource command, and I think you also have to connect using ODBC, which must be installed on your system. e.g. something like:
Sub OpenExcelDS() Dim strExcelPath As String Dim strExcelDSN As String Dim strConnection As String
' The following is the standard DSN name but change it if yours is different strExcelDSN="Excel Files" ' Substitute the pathname of your file here strExcelPath="c:\myexcelfiles\myxls.xls" strConnection = strExcelDSN & ";DBQ=" & strExcelPath & ";DriverID=790;"
' Substitute the field names etc. that you need. ActiveDocument.MailMerge.OpenDataSource _ Name:="", _ Connection:=strConnection, _ SQLStatement:="SELECT * FROM `Sheet1$` WHERE myfield like '%'2%"
End Sub
Peter Jamieson
> Thank you for this. I'm using Word 2000, so you know of anyway using this > version that I can get it to work. The database file is in Excel 2000 as [quoted text clipped - 57 lines] >> >> > >> >> > Help Anthony J. B. - 01 Jun 2006 17:01 GMT Peter, thank you sooooo much for your help. This was invaluable. Fortunately my client who I am doing this work for, had Word 2002, so I spent the afternoon with them at their office, and your instructions WORKED LIKE A CHARM. We spent a couple of hours extracting information from the database and she was very pleased. This makes me consider an upgrade at my end. Your generous response was very much appreciated. THANK YOU, THANK YOU.
> Unfortunately, the "Contains" option does not exist in Word 2000 as you > probably discovered, so to do the same thing you would have to issue the SQL [quoted text clipped - 84 lines] > >> >> > > >> >> > Help Peter Jamieson - 01 Jun 2006 19:00 GMT Glad it all worked and thanks for the feedback.
Peter Jamieson
> Peter, thank you sooooo much for your help. This was invaluable. > Fortunately my client who I am doing this work for, had Word 2002, so I [quoted text clipped - 108 lines] >> >> >> > >> >> >> > Help
|
|
|