Ms Word Database field inserts the results of a database query in a Word table.
I want to populate a Table in ms word using VBA , I already did using VBA MsAccess & MsWord bookmark , the template from the data make the document very difficult to maintain. I found MSword have the option insert database , and allow you to actualize the data in msaccess and preserve the preformating during updates . The following Database field code results from a query from my Access database through ODBC using the Database command:
{ DATABASE \d "C:\My Data Sources\To test World.odc" \c "Provider=MSDASQL.1;Persist Security Info=True;Extended Properties=\"DSN=MS Access Database;DBQ=H:\CIP BOOK\CIP2.accdb;DefaultDir=H:\CIP BOOK;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;\";Initial Catalog=H:\CIP BOOK\CIP2.accdb" \s "SELECT
Description
,TA
,Entry Title
,Memo
FROMqryTransactions ExtendedWordFill_test
WHERE ((Project_id
= 'PCP13ZOOA06'))" \l "26" \b "191" \h * MERGEFORMAT }
First my wdFieldDatabase have Fields(Index), where Index is the index number(Field object). The index number represents the position of the field in the selection, range, or document
Second I find a Fields.Add Method (Word) This example if to add a field ListNum
Selection.Collapse Direction:=wdCollapseEnd
ActiveDocument.Fields.Add Range:=Selection.Range, _
Type:=**wdFieldListNum**, Text:="\s 3"
What I want is tu update using VBA the Code in (Field codes: Database field) base on the index location and change the ( Project_id = 'PCP13ZOOA06). Other alternative can be add the field Database in specific range , location of the document using creating the code in VBA. I want to manage this from access , the idea is to create status reports with tables of expense for more than 2oo projects.