I wrote the following function and tried to execute it. However it is showing Error 13 Type Mismatch.
Public Function MyHeapBudPc(MyHeap As Long) As Double
MyHeapBudPc = "SELECT Sum(([tblPurchase]![qtyPurchasedPked]+[tblPurchase]![qtyPurchasedLoose]) " & _
"*GetLintBudgetPC([tblSeasonCenterVtyJunction]![CenterPertaining],[tblSeasonCenterVtyJunction]![VarietyPertaining],DateNo([tblPurchase]![dateOfPurchase]), " & _
"[tblFactory]![factoryType])) AS PCproduct " & _
"FROM tblSeasonCenterVtyJunction INNER JOIN (tblFactory INNER JOIN (tblHeap INNER JOIN " & _
"tblPurchase ON tblHeap.heapID = tblPurchase.heapPrepared) ON tblFactory.factoryID = tblHeap.factoryProcessed) ON " & _
"tblSeasonCenterVtyJunction.SeasonCentVtyID = tblHeap.HeapRelatedTo " & _
"WHERE (((tblPurchase.heapPrepared)= & MyHeap))"
End Function
Please help