R
Ron-Developer
Hi, I seem to have run into a problem with Word 2007. The simplified scenario
and extracted code below works for all other versions of Word, but throws up
warnings in Word 2007:
I have a table in an Access database (c:\reports.mdb) with the following
fields: ID, FirstName, Surname
In VB 6 I have the following code to insert a table of all the first names
and surnames into one word letter:
Call m_wrddocWordDocument.Range(m_wrdRange.Start,
m_wrdRange.End).InsertDatabase(Format:=0, Style:=0, LinkToSource:=False, _
Connection:="DSN=Reports", SQLStatement:="Select FirstName, Surname
from Adresses", _
PasswordDocument:="", PasswordTemplate:="",
WritePasswordDocument:="" _
, WritePasswordTemplate:="", DataSource:="C:\Reports.mdb", _
From:=-1, To:=-1, IncludeFields:=False)
When the code executes I get an "Invalid Merge Field" error for the ID field
in my database. The detail of the error is "This merge field is used in the
main document, but it does not exist in the data source". I have a choice to
remove the invalid field from the main document or to replace it with a valid
merge field (the list of valid merge fields includes just those in the select
statement above). This has to be done for every field omitted from the select
statement, but existing in the base table in Access. When the document
finally shows the table is skewed, with the ID column included with dud data.
As mentioned, this works perfectly for all other versions of Word. Can
anyone indicate why this might not be the case for Word 2007?
and extracted code below works for all other versions of Word, but throws up
warnings in Word 2007:
I have a table in an Access database (c:\reports.mdb) with the following
fields: ID, FirstName, Surname
In VB 6 I have the following code to insert a table of all the first names
and surnames into one word letter:
Call m_wrddocWordDocument.Range(m_wrdRange.Start,
m_wrdRange.End).InsertDatabase(Format:=0, Style:=0, LinkToSource:=False, _
Connection:="DSN=Reports", SQLStatement:="Select FirstName, Surname
from Adresses", _
PasswordDocument:="", PasswordTemplate:="",
WritePasswordDocument:="" _
, WritePasswordTemplate:="", DataSource:="C:\Reports.mdb", _
From:=-1, To:=-1, IncludeFields:=False)
When the code executes I get an "Invalid Merge Field" error for the ID field
in my database. The detail of the error is "This merge field is used in the
main document, but it does not exist in the data source". I have a choice to
remove the invalid field from the main document or to replace it with a valid
merge field (the list of valid merge fields includes just those in the select
statement above). This has to be done for every field omitted from the select
statement, but existing in the base table in Access. When the document
finally shows the table is skewed, with the ID column included with dud data.
As mentioned, this works perfectly for all other versions of Word. Can
anyone indicate why this might not be the case for Word 2007?