Information générale
Catégorie:
Codage, syntaxe et commandes
Ok, most likely you need sqlstatement like:
lcSQLStatement = ["SELECT * FROM db!contacts WHERE Contacts.co_primary = ?vPrimary"].
Here is the code that works for me (txt file below is delimeted file):
VBA macro code:
*.ActiveDocument.MailMerge.OpenDataSource Name:="C:\iftp_log_viewonly.txt", _
*ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
*AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
*WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
*Format:=wdOpenFormatAuto, Connection:= _
*"DSN=Text Files;DBQ=C:\;DefaultDir=C:\;DriverId=27;MaxBufferSize=2048;PageTimeout=5;" _
*, SQLStatement:="SELECT * FROM iftp_log_viewonly.txt", SQLStatement1:=""
VFP code:
.OpenDataSource(;
"C:\iftp_log_viewonly.txt",,,,,,,,,,,;
"DSN=Text Files;DBQ=C:\;DefaultDir=C:\;DriverId=27;MaxBufferSize=2048;PageTimeout=5;"+;
'SQLStatement:="SELECT * FROM iftp_log_viewonly.txt"')
As you see, sqlstatement here even does not separated by comma from the previous portion (though comma if included will not harm), but is included into the connection string with 'SQLStatement' keyword.
>Thanks for the reply. Yes I had done that (several times in fact) - when I used that connection string it brought up the messagebox that expects you to define the type of delimiter you want to use for the merge etc. This is normally caused when you do a merge into Word and choose "Foxpro Files = Word" as a datasource. I have tried also getting a connection from VBs dataenvironment tool just to compare! As I say with the oWord.ActiveDocument.MailMerge.DataSource.ConnectionString I expected to get back the correct connection string! but no joy.
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement