MS Access - 如何自定义格式自动递增字段?

MS Access - How to custom format auto-incrementing fields?

我这里有一个非常基本的 Table 游戏。

数据如下所示:

[Id]  [Description]

Id 列设置为自动递增,但它的格式不是我想要的。

示例数据如下所示:

[Id]  [Description]
GM-001 Super Mario Bros.
GM-002 The Legend of Zelda
GM-003 Super Metroid

Id 列所需的结果如下所示:

GM-1 (Super Mario Bros.)
GM-1-1 (The Legend of Zelda)
GM-1-1-1 (Super Metroid)

我当前的格式化程序是 "GM-000",但即使尝试 "GM-0" 也不行,"GM-0-0" 也行不通。我知道这不是传统的自动递增,那么有没有一种方法可以将列的格式自定义为所需的结果?

感谢并抱歉回答这个初级问题。

使用Table事件Before Change生成ID


<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<DataMacros
    xmlns="http://schemas.microsoft.com/office/accessservices/2009/11/application">
    <DataMacro Event="BeforeChange">
        <Statements>
            <ConditionalBlock>
                <If>
                    <Condition>[IsInsert]</Condition>
                    <Statements>
                        <Action Name="SetLocalVar">
                            <Argument Name="Name">prefix</Argument>
                            <Argument Name="Value">"GM -"</Argument>
                        </Action>
                        <LookUpRecord>
                            <Data Alias="gm">
                                <Query>
                                    <References>
                                        <Reference Source="Game" Alias="gm"/>
                                    </References>
                                    <Results>
                                        <Property Source="gm" Name="alternate_id"/>
                                    </Results>
                                    <Ordering>
                                        <Order Direction="Descending" Source="gm" Name="alternate_id"/>
                                    </Ordering>
                                </Query>
                                <WhereCondition>[gm].[alternate_id] Like [prefix] &amp; "*"</WhereCondition>
                            </Data>
                            <Statements>
                                <Action Name="SetLocalVar">
                                    <Argument Name="Name">prefix</Argument>
                                    <Argument Name="Value">[gm].[alternate_id] &amp; "-"</Argument>
                                </Action>
                            </Statements>
                        </LookUpRecord>
                        <Action Name="SetField">
                            <Argument Name="Field">alternate_id</Argument>
                            <Argument Name="Value">[prefix] &amp; 1</Argument>
                        </Action>
                    </Statements>
                </If>
            </ConditionalBlock>
        </Statements>
    </DataMacro>
</DataMacros>

输出


Table结构