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]));
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]));