Я создал запрос для моего ключевого показателя эффективности с "Командой", "Месяцем", "Процент пройден" в качестве ключевых данных. Что я пытаюсь выполнить сейчас, так это получить сумму «Процент пройденных» на команду (у меня есть 4 команды) в текстовом поле на основе выбранного месяца
Я создал разделенную форму, включающую мой ключданные и добавленные текстовые поля для каждой команды, где я хочу, чтобы мой процент суммирования отображался и текстовое поле использовалось в качестве поля поиска для месяца.
Я пытаюсь создать VBA для этого, который похож на функцию Dlookupно это не было успешным. Может кто-нибудь, пожалуйста, помогите мне, как я могу выполнить это?
SQL в моем запросе
SELECT
[OE Finance Tracker].Team,
[OE Finance Tracker].ERP,
[OE Finance Tracker].[Data Object],
[OE Finance Tracker].[Business Code],
[OE Finance Tracker].[Company Code],
[OE Finance Tracker].[Select],
Format([MNT Completion Date],"yyyymm") AS [Month],
[OE Finance Tracker].[Transaction Type],
IIf([Line Item Passed After Validation]<[Total Line Items Raised],[Total Line Items Raised],[Line Item Passed After Validation]) AS [Line Items],
IIf([Line Item Passed After Validation]<>[APP - Line Items Passed after Validation],[APP - Line Items Passed after Validation],IIf([MNT - Line Items Passed after validation]<>[Line Item Passed After Validation],[MNT - Line Items Passed after validation],[Line Item Passed After Validation])) AS [M15 Passed],
([M15 Passed]/[Line Items]*100) AS [M15 Percentage],
IIf([M2Req]="0","0",IIf([M2App]="0","0",IIf([M2MNT]="0","0",[Line Items]))) AS [M2 Passed],
([M2 Passed]/[Line Items]*100) AS [M2 Percentage],
IIf(IsNull([M16 Failure Reason]),[Line Items],"0") AS [M16 Passed],
([M16 Passed]/[Line Items]*100) AS [M16 Percentage],
IIf([M15 Failure Reason - APP]<>"",[M15 Failure Reason - APP],[M15 Failure Reason - MNT]) AS [M15 Failure Reason],
IIf([M15 Comments - APP]<>"",[M15 Comments - APP],[M15 Comments - MNT]) AS [M15 Specific],
IIf([M2Req]="0",[M2 Failure Reason - REQMRD Lead],IIf([M2App]="0",[M2 Failure Reason - APP],IIf([M2MNT]="0",[M2 Failure Reason - MNT],""))) AS [M2 Failure Reason],
IIf([M2Req]="0",[M2 Comments - REQ/MRD Lead],IIf([M2App]="0",[M2 Comments - APP],IIf([M2MNT]="0",[M2 Comments - MNT],""))) AS [M2 Failure Specific],
IIf([M16 Failure Reason]<>"",[M16 Failure Reason]) AS [M16 Failure Reasons],
IIf([M16 Comments]<>"",[M16 Comments]) AS [M16 Failure Specifics],
IIf([Line Item Passed After Validation]<[Total Line Items Raised],[Total Line Items Raised],[Line Item Passed After Validation]) AS [Line ItemsM16],
[OE Finance Tracker].[Request Number],
[OE Finance Tracker].[Maintainer Assigned],
[OE Finance Tracker].[MRD RequestorLead Assigned],
[OE Finance Tracker].[Approver Assigned],
[OE Finance Tracker].[Total line items Processed],
[OE Finance Tracker].[APP - Line Items Passed after Validation],
[OE Finance Tracker].[MNT - Line Items Passed after validation],
[OE Finance Tracker].[Total Line Items Raised],
[OE Finance Tracker].[Request Type],
[OE Finance Tracker].[Mantainer Status],
[OE Finance Tracker].[Line Item Passed After Validation],
[OE Finance Tracker].[M2 Failure Reason - REQMRD Lead],
[OE Finance Tracker].[M2 Comments - REQ/MRD Lead],
IIf(IsNull([M2 Failure Reason - REQMRD Lead]),[Line Items],"0") AS M2Req,
[OE Finance Tracker].[M15 Failure Reason - APP],
[OE Finance Tracker].[M15 Comments - APP],
[OE Finance Tracker].[M2 Failure Reason - APP],
[OE Finance Tracker].[M2 Comments - APP],
IIf(IsNull([M2 Failure Reason - APP]),[Line Items],"0") AS M2APP,
[OE Finance Tracker].[M15 Failure Reason - MNT],
[OE Finance Tracker].[M15 Comments - MNT],
[OE Finance Tracker].[M2 Failure Reason - MNT],
[OE Finance Tracker].[M2 Comments - MNT],
IIf(IsNull([M2 Failure Reason - MNT]),[Line Items],"0") AS M2MNT,
[OE Finance Tracker].[M16 Failure Reason],
[OE Finance Tracker].[M16 Comments]
FROM
[OE Finance Tracker]
WHERE
((([OE Finance Tracker].[Request Type])="Request") AND
(([OE Finance Tracker].[Mantainer Status])="Completed"));