Results 1 to 3 of 3

Thread: Word Merge

  1. #1
    Join Date
    Jul 2012
    Posts
    2

    Unanswered: Word Merge

    Hello I have a database to track work orders. Each workorder has one part#. Each part# has a 2 page inspection report page created in Word. (1 page for the workorder info (CustomerID, Serial# etc along with other info that does not come from Access and the other page is a drawing). I would like to have a command button on the form to open the word document for the part and merge the WO info. I created a table with 2 fields (InspectionReportID and InspectionReportPath) and a field in the Parts table with the InspectionReportID for the inspection report for the part. I can get the specific report to open but I do not know how to merge the fields with the WOinfo. The code I have on the command button to open the word document is
    DoCmd.SetWarnings False

    Dim C20GBCOV As String
    Dim OpenWord As Object

    'Path to word document
    C20GBCOV = InspectionFormQry(Me.PartID)

    'Create instance of Word
    Set OpenWord = CreateObject("Word.Application")
    OpenWord.Visible = True

    'Open the document
    OpenWord.Documents.Open FileName:=C20GBCOV

    DoCmd.SetWarnings True

    and the query is

    SELECT InspectionFormsTable.InspectionFormPath, PartsTable.PartID
    FROM InspectionFormsTable INNER JOIN PartsTable ON InspectionFormsTable.InspectionFormID = PartsTable.InspectionForm
    WHERE (((PartsTable.PartID)=[PartID_par]));

  2. #2
    Join Date
    Jul 2012
    Posts
    4
    You should place one Bookmark on your Word file (name bmkWoinfo for examples), then open Table using these code:

    dim rs As RecordSet
    Set rs = CurrentProject.OpenTables("tableName")
    then merge field to Word like this: YourWordObject.ActiveDocuments.bmkWoinfo.TypeText Text= rs!FieldName

  3. #3
    Join Date
    Jul 2012
    Posts
    2

    Word Merge

    Hi-thanks for your reply. On the WorkOrder form I select a Customer ID then a PartNo from combo boxes and type a Serial# & PO# into text fields. Each part has an inspection report. There is a field in the parts table for the path to the associated inspection report (Word Doc). The command button I have now will open the correct inspection report but I would like the workorder info to be merged to the Inspection report by clicking the command button. Also the current code opens the Inspection report but it is not visible on the screen.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •