: This message was edited by Jademonkey2k at 2005-1-20 9:56:53
: Hiya peeps,
: jus waqndering if anyone can help, iv made a form in Access and i am able to navigate records via it, easy right lol? well im trying to make a button that when clicked takes the current record and merges it with a ready made mail merge Word document, iv managed to comple this and make it work to a certain extent its just it doesnt merge the one record, it merges them all? i only want it to merge the current record, i dont know if anyone can help me with this? i'll put the code im using in a VBA module below, if anyone can tell me what im doing wrong or has a solution i would be greatful.
: Function MergeIt()
: Dim ObjWord As Word.Document
: Set ObjWord = GetObject("C:\Documents and Settings\Administrator\Desktop\Database Project\Master Thank You Letter.doc", "Word.Document")
: ObjWord.Application.Visible = True
: ObjWord.MailMerge.OpenDataSource _
: Name:="C:\Documents and Settings\Administrator\Desktop\Database Project\Database 1.mdb", _
: LinkToSource:=True, Connection:="TABLE Main_Contracts_Database", _
: SQLStatement:="SELECT * FROM [Main_Contracts_Database]"
: End Function
It appears that your mail merge source is the table that you are viewing in your Access app. You are probably navigating through your complete set of records when you are viewing in the form. When you do a merge you are telling your app to merge the complete set of records there are no filters applied. Therefore you get all the records merged.
There are probably a couple of ways arround this. I think the best way would be to make a temporary recordset or table and use that as the source of the merge. Or you could apply a filter to the current recordset and then merge it. You would have to remove the filter after the merge or you will not be able to see any more records in the form.
Hope this helps