Hi guys,
I have a query that I wish to call via VBA and display the results as a PivotChart.
I also want to pass it a parameter to enable me to restrict the amount of data being displayed.
I use a command button on a form to trigger the VBA Event>
Here is my code:
Dim sWHERE As String
sWHERE = "[PartID] = " & Me.PartID
DoCmd.OpenQuery "qDisplayPartSoldHistory", acViewPivotChart
I understand that the Openquery does not have the ability to pass parameters like the Openform does. I have googled this issue but don't really understand the solutions they offer so I have come back to my favorite forum for some help.
I basically want to pass the "Me.PartID" automatically that is on the parent form to the query when it is run (qDisplayPartSoldHistory) when the command button is clicked.
Here is the source of qDisplayPartSoldHistory:
SELECT [Workorder Parts].*, Workorders.*, Customers.*, Workorders.Valid, Workorders.DateReceived, [Workorder Parts].PartID
FROM (Customers INNER JOIN Workorders ON Customers.CustomerID = Workorders.CustomerID) INNER JOIN [Workorder Parts] ON Workorders.WorkorderID = [Workorder Parts].WorkorderID
WHERE (((Workorders.Valid)=Yes) AND (([Workorder Parts].PartID)=[Parameter]))
ORDER BY Workorders.DateReceived;
Thanks for your help.
Cheers
Greg
I have a query that I wish to call via VBA and display the results as a PivotChart.
I also want to pass it a parameter to enable me to restrict the amount of data being displayed.
I use a command button on a form to trigger the VBA Event>
Here is my code:
Dim sWHERE As String
sWHERE = "[PartID] = " & Me.PartID
DoCmd.OpenQuery "qDisplayPartSoldHistory", acViewPivotChart
I understand that the Openquery does not have the ability to pass parameters like the Openform does. I have googled this issue but don't really understand the solutions they offer so I have come back to my favorite forum for some help.
I basically want to pass the "Me.PartID" automatically that is on the parent form to the query when it is run (qDisplayPartSoldHistory) when the command button is clicked.
Here is the source of qDisplayPartSoldHistory:
SELECT [Workorder Parts].*, Workorders.*, Customers.*, Workorders.Valid, Workorders.DateReceived, [Workorder Parts].PartID
FROM (Customers INNER JOIN Workorders ON Customers.CustomerID = Workorders.CustomerID) INNER JOIN [Workorder Parts] ON Workorders.WorkorderID = [Workorder Parts].WorkorderID
WHERE (((Workorders.Valid)=Yes) AND (([Workorder Parts].PartID)=[Parameter]))
ORDER BY Workorders.DateReceived;
Thanks for your help.
Cheers
Greg