2010/05/01

access2010 データマクロで累計 -AfterInsert-

データマクロで累計を計算させてみる-挿入後処理-
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<DataMacros xmlns="http://schemas.microsoft.com/office/accessservices/2009/11/application">
  <DataMacro Event="AfterInsert">
    <Statements>
      <ForEachRecord>
        <Data Alias="t1_0">
          <Reference>t1</Reference>
        </Data>
        <Statements>
          <Action Name="SetLocalVar">
            <Argument Name="Name">tmpsub</Argument>
            <Argument Name="Value">0</Argument>
          </Action>
          <ForEachRecord>
            <Data Alias="t1_1">
              <Reference>t1</Reference>
              <WhereCondition>[t1_1].[ID]&lt;=[t1_0].[ID]</WhereCondition>
            </Data>
            <Statements>
              <Action Name="SetLocalVar">
                <Argument Name="Name">tmpsub</Argument>
                <Argument Name="Value">[t1_1].[f_num]+[tmpsub]</Argument>
              </Action>
            </Statements>
          </ForEachRecord>
          <EditRecord>
            <Data />
            <Statements>
              <Action Name="SetField">
                <Argument Name="Field">t1_0.f_sum</Argument>
                <Argument Name="Value">[tmpsub]</Argument>
              </Action>
            </Statements>
          </EditRecord>
        </Statements>
      </ForEachRecord>
    </Statements>
  </DataMacro>
</DataMacros>

0 件のコメント: