D
Dale
Helo all,
Could someone help me?
I create a Address Simulation Report for all the mailmerges I do. I choose
a representative sample of the mailmerge data using the MOD function.
I have the following which works as far as it goes. I'd like to choose
also the very last record of any data file I attach to. I've tried
searching the web but I can't seem to find any more complex examples than
just SELECT * FROM XXX. I've also tried several trial and error solutions
but I just can't seem to make it work properly.
' open connection to populate RecordCount
With Dialogs(wdDialogMailMergeOpenDataSource)
.Name = "J:\ML\" & PATH & "\ADR\" & FileName
.Execute
RecordCount = ActiveDocument.MailMerge.DataSource.RecordCount
'determine total records in the data
temp = RecordCount / numLabels ' numLabels = number of address
simulations I want to generate
Divisor = Int(temp)
End With 'end of open data
With Dialogs(wdDialogMailMergeOpenDataSource)
.Name = "J:\ML\" & PATH & "\ADR\" & FileName
' choose every (pc_no_seg MOD " & Divisor & " = 1) record. pc_no_seg is
a sequential number in the data
myQuery = "SELECT * FROM " & FileName & " WHERE (pc_no_seg MOD " &
Divisor & " = 1)" ' WORKS but I want to select the LAST record also.
.SQLStatement = myQuery
.Execute
End With 'end of open data
How would I modify this SQLStatement to include the very last record?
Thanx
Dale Jones
Could someone help me?
I create a Address Simulation Report for all the mailmerges I do. I choose
a representative sample of the mailmerge data using the MOD function.
I have the following which works as far as it goes. I'd like to choose
also the very last record of any data file I attach to. I've tried
searching the web but I can't seem to find any more complex examples than
just SELECT * FROM XXX. I've also tried several trial and error solutions
but I just can't seem to make it work properly.
' open connection to populate RecordCount
With Dialogs(wdDialogMailMergeOpenDataSource)
.Name = "J:\ML\" & PATH & "\ADR\" & FileName
.Execute
RecordCount = ActiveDocument.MailMerge.DataSource.RecordCount
'determine total records in the data
temp = RecordCount / numLabels ' numLabels = number of address
simulations I want to generate
Divisor = Int(temp)
End With 'end of open data
With Dialogs(wdDialogMailMergeOpenDataSource)
.Name = "J:\ML\" & PATH & "\ADR\" & FileName
' choose every (pc_no_seg MOD " & Divisor & " = 1) record. pc_no_seg is
a sequential number in the data
myQuery = "SELECT * FROM " & FileName & " WHERE (pc_no_seg MOD " &
Divisor & " = 1)" ' WORKS but I want to select the LAST record also.
.SQLStatement = myQuery
.Execute
End With 'end of open data
How would I modify this SQLStatement to include the very last record?
Thanx
Dale Jones