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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parameters for MS Access Query 1

Status
Not open for further replies.

Axoliien

Programmer
Aug 19, 2003
166
US
I am trying to write a set of functions to allow a user to open a template and perform a mail merge on that template. I have asked this before, however the answer I received does not seem applicable to my needs.

We have the following specifications:
[ul]
[li]We have an MS Word template that we want to open and perform a merge.[/li]
[li]We have our query in the MDB that we want to reference into the MS Word template.[/li]
[li]The query has a parameter named IDNum that we want to fill[/li]
[/ul]

We want to perform the following actions:
[ol]
[li]Assume we are in access and have opened the template.[/li]
[li]Assume we have connected the template to the query in the mdb[/li]
[li]Pass a value to the parameter in the access query during mail merge[/li]
[/ol]

I was told to use the QueryDefs object to pass parameters. The problem is that we are opening a mdb query from a word template, so we cannot pass parameters to the query using the QueryDefs object. Anyone have any clues?

Thanks!
 
You can use QueryDefs to re-write the SQL behind the query before allowing the mailmerge to connect to the data. If it is something as simple as "SELECT * FROM [tblYourTable] WHERE [IDNum] = 3;" then it is fairly simple, somthing like:

currentDB.QueryDefs("qryYourQuery").SQL = strSQL

HTH
Peter

[η][β][π]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top