Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 2nd, 2007, 05:41 PM
Registered User
 
Join Date: Jul 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default mail merging from a query

I am the admin for a database that has client records. I need to mail merge data from a query, but need to pass two variables to the query before I merge the results of it. I want the user to be able to run a command and be prompted for two variables and then have access merge it results of that query (or SELECT statement) with one button. In the past I have been having the end-user edit a query in design mode, save it, and then run the merge from that query that already has criteria in it.

I would love to do it in VBA and SQL. Where can I find some code for this type of subroutine?

 
Old July 3rd, 2007, 11:04 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

This is very elementary. If you just want them to be prompted for variables, put these statements in the criteria line (in the query designer) (ex.):

This is a straight parameter
[Please enter the first parameter:]

These are like parameters:
Like [Please enter the first letters of the last name:] & "*"
Like "*" & [Please enter any characters in the string:] & "*"

This is two parameters for a date column:
Between [Please enter start date:] And [Please enter end date:]

You can also have the query fetch the parameter from a combo box or text box, but this limits its use to the one form:
[Forms]![frmMyForm].[cboMyCOmboBox]

This should get you started. You can also search help for query parameters.

HTH

mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
Send mail and attachments with PHP mail function Lofa Beginning PHP 1 June 2nd, 2008 03:24 PM
General Mail Merge Query iaingblack Word VBA 0 March 12th, 2007 05:01 PM
Mail Merge VBA Query jayp Excel VBA 1 October 14th, 2005 05:25 PM
mail merge from query nabrown78 Access VBA 3 April 4th, 2005 08:23 PM
Automatic E-mail Generated based on query smartgir Access VBA 4 March 25th, 2004 09:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.