Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Roberto
 
Posts: n/a
Default Opendatasource sqlstatement

Hi, I tried to merge using a SQL statement longer than 255 ch. but the
connection fails. In Sqlstatement1 property I write the second part of the
string which contains only a simple ORDER BY statement. Only Sqlstatement1=""
is accepted. Any suggestion?
This is the code with simplified SQL statement (it doesn't work anyway):
'-----------------------------------------------
Sub trial()
Dim mydoc As Word.Application,
Dim mysql1 As String, mysql2 As String, myconnectionstring As String
Set mydoc = ActiveDocument.Application
myconnectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Password=" & Chr(34)
& Chr(34) & ";User ID=Admin;Data
Source=C:\TRIAL\mydata.mdb;Mode=Read;Extended Properties=" & Chr(34) &
Chr(34) & ";Jet OLEDBatabase Password=" & Chr(34) & Chr(34)

mysql1 = "SELECT MyTable.* FROM MyTable WHERE MyTable .SURNAME=""Smith"""
mysql2 = " ORDER BY SURNAME"
mydoc.Documents.Add , 0

mydoc.ActiveDocument.MailMerge.MainDocumentType = 3


mydoc.ActiveDocument.MailMerge.OpenDataSource Name:= _
"C:\TRIAL\mydata.mdb", ConfirmConversions:=False, ReadOnly:=False _
, LinkToSource:=True, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", WritePasswordDocument:="",
WritePasswordTemplate:= _
"", Revert:=False, Format:=0, Connection:=myconnectionstring _
, SQLStatement:=mysql1, SQLStatement1:=mysql2


mydoc.ActiveDocument.MailMerge.EditMainDocument

End Sub

'--------------------------------------
Thanks,
Roberto
 
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenDataSource Excel appears in taskbar Michael M. Emmons Mailmerge 0 October 28th 05 08:09 PM
OpenDataSource Word 2000/2002/2003 Dick Stevens Mailmerge 3 March 30th 05 10:35 PM
OpenDataSource still asks for a table name Don Petersen via OfficeKB.com Mailmerge 4 March 11th 05 07:06 PM
bug with OpenDataSource Michel Mailmerge 0 February 3rd 05 04:21 PM
OpenDataSource problem Phill Mailmerge 1 January 29th 05 08:58 AM


All times are GMT +1. The time now is 03:52 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"