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

Mail merge from access

Status
Not open for further replies.

Jdubs

Technical User
Apr 3, 2003
11
GB
I have designed a database such that when I click my 'create letter' button in the form it auto open word and mail merges the data from that record, I have a problem that sometimes the word macro opens another instance of access and therefore not selecting the record I was viewing in the form. Could anyone tell me a way round this please? Thanks Jdubs
 
I'm guessing that you have your Word document's datasource set to a query. Set that query in code to the record you are currently viewing before calling the code to open Word.
Public Sub SetQuery(strQueryName As String, strSQL As String)
'set the query from which the merge document will pull its info
Dim qdfNewQueryDef As QueryDef
Set qdfNewQueryDef = CurrentDb.QueryDefs(strQueryName)
qdfNewQueryDef.Sql = strSQL
qdfNewQueryDef.Close
RefreshDatabaseWindow
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top