[英]Is there a way for end users to use the current filter set in Access as the datasource for a Word mailmerge?
One of our products is an Access database which includes a table listing thousands of addresses.我们的产品之一是 Access 数据库,其中包含一个列出数千个地址的表格。 Our product includes a user friendly interface for searching and filtering out the addresses.我们的产品包括一个用户友好的界面,用于搜索和过滤地址。 These are displayed on a form, let's call it frmAddress.这些显示在一个表单上,我们称之为 frmAddress。
We include on frmAddress an Export To Excel button which takes the current filter set and exports it to Excel.我们在 frmAddress 上包含一个导出到 Excel 按钮,该按钮获取当前过滤器集并将其导出到 Excel。
To use their filtered addresses as a datasource for a Word mailmerge, end users export to Excel first then used the Excel file as the datasource.要将过滤后的地址用作 Word 邮件合并的数据源,最终用户首先导出到 Excel,然后使用 Excel 文件作为数据源。
But this is rather a long way round.但这是一个相当长的路要走。 Is there a way to connect directly to Access and pull out the addresses (the current filter set in frmAddress, not the full table)?有没有办法直接连接到 Access 并提取地址(在 frmAddress 中设置的当前过滤器,而不是完整的表)? If it can't be done directly is there anything that comes close?如果不能直接完成,有什么可以接近的吗?
The nearest thing I can think of is to save the current filter set every time it changes as the CommandText of a dynamic query, but it seems to me that in Word 2003 Access Queries (unlike Tables) aren't reliably visible for mailmerge purposes.我能想到的最接近的事情是将当前过滤器集每次更改为动态查询的 CommandText 时保存,但在我看来,在 Word 2003 中,访问查询(与表不同)对于邮件合并目的并不可靠。
If you download my code library here: http://www.kallal.ca/msaccess/msaccess.html如果你在这里下载我的代码库: http://www.kallal.ca/msaccess/msaccess.html
(super easy word merge) (超级简单的单词合并)
Then, the code you need for the merge is:然后,合并所需的代码是:
Dim strSql as string
strSql = "select * from tblCustomers where " & me.Filter
MergeAllWord strSql
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.