hello, thanks for your interest. You are right, of course. It seems I managed to make some progress resorting to the lazy practice of recording a macro. So I linked to my table in a new word document, and recorded two macros, one linking to the sql table and one linking to the access table linked to the real sql. those are the results
Code:
'link to sql table, native driver 11.1
'MailMerge selected records from table to Word document
With WordApp
.ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
.ActiveDocument.MailMerge.OpenDataSource Name:= _
"C:\Users\User\Documents\My Data Sources\RicevuteCPNVersion2 LibroSoci.odc" _
, ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, Connection:= _
"Provider=SQLNCLI11.1;Integrated Security=SSPI;Persist Security Info=False;User ID="""";Initial Catalog=RicevuteCPNVersion2;Data Source=DESKTOP-FMBJ0FJ\SQLEXPRESS;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=DESKTOP-FMBJ0FJ" _
, SQLStatement:="SELECT * FROM ""LibroSoci"" WHERE [Numero Tessera] =" & Numerotessera, SQLStatement1:="", SubType _
:=wdMergeSubTypeOther
'link to linked access table
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource Name:= _
"C:\Users\User\Documents\My Data Sources\(Default) dbo_LibroSoci.odc", _
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, Connection:= _
"Provider=Microsoft.ACE.OLEDB.16.0;Password="""";User ID=Admin;Data Source=c:\testhyp2\RicevuteconprimanotaFE.accdb;Mode=Share Deny None;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:E" _
, SQLStatement:="SELECT * FROM `dbo_LibroSoci`", SQLStatement1:="", _
SubType:=wdMergeSubTypeOther
Now the link to the real sql table seems to work, whereas the other shows the old error failing to open the connection. But both links work fine in the word test file.I am working on it, it seens more logical to refer to the access table, also because the other forms in the frontend refer to it. Thanks again for your interest