J
jman
I have a form 'Failure Mode and Effects Analysis' that also contains a linked
subform from the table 'Failure Details.' I am trying to create a report
preview button that will only preview the current form and subform. My report
is created off a query called 'Failure Mode and Effects Analysis Query.' The
report name is 'Failure Mode and Effects Analysis.'
Here is my SQL for the query:
SELECT [Failure Details].PartID, [Part Details].[Part Number], [Part
Details].Customer, [Part Details].[Revision Level], [Failure Mode and Effects
Analysis].[PREPARED BY:], [Failure Mode and Effects Analysis].[PART
FUNCTION:], [Failure Mode and Effects Analysis].[DATE:], [Failure
Details].OPERATION, [Failure Details].[FAILURE MODE], [Failure
Details].[CAUSE OF FAILURE], [Failure Details].[EFFECT OF FAILURE], [Failure
Details].[CURRENT CONTROLS], [Failure Details].P, [Failure Details].S,
[Failure Details].D, [Failure Details].R, [Failure Details].[RECOMMENDED
CORRECTAVE ACTIONS], [Failure Details].[ACTIONS TAKEN], [Failure Details].P_,
[Failure Details].S_, [Failure Details].D_, [Failure Details].R_, [Failure
Details].[DEPARTMENT RESPONSIBLE], [Failure Mode and Effects
Analysis].FailureID
FROM [Failure Mode and Effects Analysis] AS [Failure Mode and Effects
Analysis_1] INNER JOIN (([Part Details] INNER JOIN [Failure Details] ON [Part
Details].PartID = [Failure Details].PartID) INNER JOIN [Failure Mode and
Effects Analysis] ON [Part Details].PartID = [Failure Mode and Effects
Analysis].PartID) ON [Failure Mode and Effects Analysis_1].PartID = [Failure
Details].PartID;
Now this is the code I'm attempting to put in the Click event of the preview
button.
Private Sub CmdPreview_Click()
On Error GoTo Err_CmdPreview_Click
Dim stDocName As String
stDocName = "Failure Mode and Effects Analysis"
DoCmd.OpenReport stDocName, acPreview
Queries![Failure Mode and Effects Analysis Query].Filter = "FailureID ="
& Me![FailureID]
Queries![Failure Mode and Effects Analysis Query].FilterOn = True
Reports![Failure Mode and Effects Analysis].Filter = "FailureID =" &
Me![FailureID]
Reports![Failure Mode and Effects Analysis].FilterOn = True
Dim FormName As String
FormName = "Failure Mode and Effects Analysis"
DoCmd.Save acForm, FormName
DoCmd.Close acForm, FormName
Exit_CmdPreview_Click:
Exit Sub
Err_CmdPreview_Click:
MsgBox Err.Description
Resume Exit_CmdPreview_Click
End Sub
I put the save and close commands so if any new data is entered into the
form, it will be reflected in the report preview. Whenever I click the
preview report button, the report come saying "Object Required." and when you
click OK it just returns the normal report preview view with all records and
not just the one I wanted.
When I delete the 2 lines beginning with Queries, which is how the code is
in all my other reports without a subform/query, I get the following message:
"Extra ) in query expression '(FailureID=)'."
subform from the table 'Failure Details.' I am trying to create a report
preview button that will only preview the current form and subform. My report
is created off a query called 'Failure Mode and Effects Analysis Query.' The
report name is 'Failure Mode and Effects Analysis.'
Here is my SQL for the query:
SELECT [Failure Details].PartID, [Part Details].[Part Number], [Part
Details].Customer, [Part Details].[Revision Level], [Failure Mode and Effects
Analysis].[PREPARED BY:], [Failure Mode and Effects Analysis].[PART
FUNCTION:], [Failure Mode and Effects Analysis].[DATE:], [Failure
Details].OPERATION, [Failure Details].[FAILURE MODE], [Failure
Details].[CAUSE OF FAILURE], [Failure Details].[EFFECT OF FAILURE], [Failure
Details].[CURRENT CONTROLS], [Failure Details].P, [Failure Details].S,
[Failure Details].D, [Failure Details].R, [Failure Details].[RECOMMENDED
CORRECTAVE ACTIONS], [Failure Details].[ACTIONS TAKEN], [Failure Details].P_,
[Failure Details].S_, [Failure Details].D_, [Failure Details].R_, [Failure
Details].[DEPARTMENT RESPONSIBLE], [Failure Mode and Effects
Analysis].FailureID
FROM [Failure Mode and Effects Analysis] AS [Failure Mode and Effects
Analysis_1] INNER JOIN (([Part Details] INNER JOIN [Failure Details] ON [Part
Details].PartID = [Failure Details].PartID) INNER JOIN [Failure Mode and
Effects Analysis] ON [Part Details].PartID = [Failure Mode and Effects
Analysis].PartID) ON [Failure Mode and Effects Analysis_1].PartID = [Failure
Details].PartID;
Now this is the code I'm attempting to put in the Click event of the preview
button.
Private Sub CmdPreview_Click()
On Error GoTo Err_CmdPreview_Click
Dim stDocName As String
stDocName = "Failure Mode and Effects Analysis"
DoCmd.OpenReport stDocName, acPreview
Queries![Failure Mode and Effects Analysis Query].Filter = "FailureID ="
& Me![FailureID]
Queries![Failure Mode and Effects Analysis Query].FilterOn = True
Reports![Failure Mode and Effects Analysis].Filter = "FailureID =" &
Me![FailureID]
Reports![Failure Mode and Effects Analysis].FilterOn = True
Dim FormName As String
FormName = "Failure Mode and Effects Analysis"
DoCmd.Save acForm, FormName
DoCmd.Close acForm, FormName
Exit_CmdPreview_Click:
Exit Sub
Err_CmdPreview_Click:
MsgBox Err.Description
Resume Exit_CmdPreview_Click
End Sub
I put the save and close commands so if any new data is entered into the
form, it will be reflected in the report preview. Whenever I click the
preview report button, the report come saying "Object Required." and when you
click OK it just returns the normal report preview view with all records and
not just the one I wanted.
When I delete the 2 lines beginning with Queries, which is how the code is
in all my other reports without a subform/query, I get the following message:
"Extra ) in query expression '(FailureID=)'."