i have a table that has like 6 records in it and i want to merge only the one that is being viewed. my code only merges the last one. can someone help?
my code::::
Private Sub Command1_Click()
Set oApp = CreateObject("Word.Application")
Set oDoc = oApp.Documents.Add(conagnoa)
oDoc.MailMerge.OpenDataSource Name:="C:\Documents and Settings\m4imprlp\Desktop\redi\db2.mdb", _
Connection:="TABLE tblAGNOA", SQLStatement:="SELECT * FROM [tblAGNOA]"
With oDoc.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.firstRecord = wdDefaultfirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute pause:=True
End With
oApp.Visible = True
oDoc.Close savechanges:=wdDoNotSaveChanges
oApp.ScreenUpdating = True
Set oApp = Nothing
Set oDoc = Nothing
End Sub