Y
YT
Hi,
I have a problem connecting to data source in mail merge.
I created a datasource through the Select Data Source screen to connect to SQL Server. And everything was fine. Then I recorded a process to open this datasource on a macro and run it, and it returned a message
Record 1 contained too few data fields, Record 2 contained too few data fields, ... (3 times, because the table that I connected to has 3 columns), and I clicked OK each time.
Then it returned with Invalid Merge Field, and on it is has this
This merge field is used in the main document, but it does not exist in the data source [FieldName
-----------------------------------------------------------------------------------------------------------------
You can remove the invalid merge field from the main document. [Remove Field button
-----------------------------------------------------------------------------------------------------------------
Or, you can replace it with a valid merge field from the data source [M__ (drop down combo box)
Sample data
[empty box] [OK button] [Cancel button
------------------------------------------------------------------------------------------------------------------
Now, the thing is that M__ field does not even exist in the table that I connect to.
If I click OK, then it just returned empty string.
If I click Remove Field Button, then it removes the merge field
If I click Cancel, then it returned 'Error! MergeField was not found in header record of data source.
When I step into the code in VB Editor, the error happened when trying to set the datasource
----------------------------------------------------------------------------------------------------------------------------------
ActiveDocument.MailMerge.OpenDataSource Name:=
"C:\Documents and Settings\yenny\My Documents\My Data Sources\svr_sql_itdev Cis_Dev vFactFindClient.odc"
, ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True,
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="",
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False,
Format:=wdOpenFormatAuto, Connection:=
"Provider=SQLOLEDB.1;Password=unisys;Persist Security Info=True;User ID=ordcisuser;Initial Catalog=Cis_Dev;Data Source=svr_sql_itdev;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=SVR_DOT_NET;Use Encryption for Data=False;T"
, SQLStatement:="SELECT * FROM ""vFactFindClient""", SQLStatement1:="",
SubType:=wdMergeSubTypeOthe
-------------------------------------------------------------------------------------------------------------------------------------------
Does anyone have any idea on how to proceed from here
Thanks.
Yenn
I have a problem connecting to data source in mail merge.
I created a datasource through the Select Data Source screen to connect to SQL Server. And everything was fine. Then I recorded a process to open this datasource on a macro and run it, and it returned a message
Record 1 contained too few data fields, Record 2 contained too few data fields, ... (3 times, because the table that I connected to has 3 columns), and I clicked OK each time.
Then it returned with Invalid Merge Field, and on it is has this
This merge field is used in the main document, but it does not exist in the data source [FieldName
-----------------------------------------------------------------------------------------------------------------
You can remove the invalid merge field from the main document. [Remove Field button
-----------------------------------------------------------------------------------------------------------------
Or, you can replace it with a valid merge field from the data source [M__ (drop down combo box)
Sample data
[empty box] [OK button] [Cancel button
------------------------------------------------------------------------------------------------------------------
Now, the thing is that M__ field does not even exist in the table that I connect to.
If I click OK, then it just returned empty string.
If I click Remove Field Button, then it removes the merge field
If I click Cancel, then it returned 'Error! MergeField was not found in header record of data source.
When I step into the code in VB Editor, the error happened when trying to set the datasource
----------------------------------------------------------------------------------------------------------------------------------
ActiveDocument.MailMerge.OpenDataSource Name:=
"C:\Documents and Settings\yenny\My Documents\My Data Sources\svr_sql_itdev Cis_Dev vFactFindClient.odc"
, ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True,
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="",
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False,
Format:=wdOpenFormatAuto, Connection:=
"Provider=SQLOLEDB.1;Password=unisys;Persist Security Info=True;User ID=ordcisuser;Initial Catalog=Cis_Dev;Data Source=svr_sql_itdev;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=SVR_DOT_NET;Use Encryption for Data=False;T"
, SQLStatement:="SELECT * FROM ""vFactFindClient""", SQLStatement1:="",
SubType:=wdMergeSubTypeOthe
-------------------------------------------------------------------------------------------------------------------------------------------
Does anyone have any idea on how to proceed from here
Thanks.
Yenn