The first method I tried to populate the textboxes was by setting the control source under the properties tab using the following function:
Code: Select all
=DLookUp( [qryCombineCounts]![CountOfResult1ID] ,"qryCombineCounts", [qryCombineCounts]![SupplierID] = [cmbSupplierName] , [qryCombineCounts]![TestTypeID] = 1, [qryCombineCounts]![ResultID] = 1)
or
=DLookUp( [qryCombineCounts]![CountOfResult1ID] ,[qryCombineCounts], [qryCombineCounts]![SupplierID] = [cmbSupplierName] , [qryCombineCounts]![TestTypeID] = 1, [qryCombineCounts]![ResultID] = 1)
of which I got a #Type error. The second method I tried was by setting the value via VBA on the On Load event using the following code:
Code: Select all
Private Sub Report_Load()
'Result 1 summary
Me.txtCountX11_1.Value = DLookup("[CountOfResult1ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 1 AND [ResultID] = 1")
Me.txtCountX12_1.Value = DLookup("[CountOfResult1ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 1 AND [ResultID] = 2")
Me.txtCountX13_1.Value = DLookup("[CountOfResult1ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 1 AND [ResultID] = 3")
Me.txtCountX21_1.Value = DLookup("[CountOfResult1ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 2 AND [ResultID] = 1")
Me.txtCountX22_1.Value = DLookup("[CountOfResult1ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 2 AND [ResultID] = 2")
Me.txtCountX23_1.Value = DLookup("[CountOfResult1ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 2 AND [ResultID] = 3")
Me.txtCountX31_1.Value = DLookup("[CountOfResult1ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 3 AND [ResultID] = 1")
Me.txtCountX32_1.Value = DLookup("[CountOfResult1ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 3 AND [ResultID] = 2")
Me.txtCountX33_1.Value = DLookup("[CountOfResult1ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 3 AND [ResultID] = 3")
'Result 2 summary
Me.txtCountX11_2.Value = DLookup("[CountOfResult2ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 1 AND [ResultID] = 1")
Me.txtCountx12_2.Value = DLookup("[CountOfResult2ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 1 AND [ResultID] = 2")
Me.txtCountx13_2.Value = DLookup("[CountOfResult2ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 1 AND [ResultID] = 3")
Me.txtCountx21_2.Value = DLookup("[CountOfResult2ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 2 AND [ResultID] = 1")
Me.txtCountx22_2.Value = DLookup("[CountOfResult2ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 2 AND [ResultID] = 2")
Me.txtCountx23_2.Value = DLookup("[CountOfResult2ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 2 AND [ResultID] = 3")
Me.txtCountx31_2.Value = DLookup("[CountOfResult2ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 3 AND [ResultID] = 1")
Me.txtCountx32_2.Value = DLookup("[CountOfResult2ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 3 AND [ResultID] = 2")
Me.txtCountx33_2.Value = DLookup("[CountOfResult2ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 3 AND [ResultID] = 3")
'Result 3 summary
Me.txtCountx11_3.Value = DLookup("[CountOfResult3ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 1 AND [ResultID] = 1")
Me.txtCountx12_3.Value = DLookup("[CountOfResult3ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 1 AND [ResultID] = 2")
Me.txtCountx13_3.Value = DLookup("[CountOfResult3ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 1 AND [ResultID] = 3")
Me.txtCountx21_3.Value = DLookup("[CountOfResult3ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 2 AND [ResultID] = 1")
Me.txtCountx22_3.Value = DLookup("[CountOfResult3ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 2 AND [ResultID] = 2")
Me.txtCountx23_3.Value = DLookup("[CountOfResult3ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 2 AND [ResultID] = 3")
Me.txtCountx31_3.Value = DLookup("[CountOfResult3ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 3 AND [ResultID] = 1")
Me.txtCountx32_3.Value = DLookup("[CountOfResult3ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 3 AND [ResultID] = 2")
Me.txtCountx33_3.Value = DLookup("[CountOfResult3ID]", "qryCombineCounts", "[SupplierID]= " & Me.cmbSupplierName.Value & " AND [TestTypeID] = 3 AND [ResultID] = 3")
End Sub
The above code works for me on the first instance of Me.cmbSupplierName.Value (the SupplierName field on the report is a combobox with the bound column being SupplierID). Once the report goes to the next section (I have a section breaks on the supplier field), the table displays with the same information as in the last section which tells me that either the above code is not in the right event for the report or that it does not change the value of Me.cmbSupplierName.Value in the code after each new section. Am I am going about this all wrong?