MS Access 重启编号序列 [英] MS Access Restart Number Sequence

查看:42
本文介绍了MS Access 重启编号序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在 MS Access 中进行序列计数,其中计数序列根据另一个字段重置,如下示例,试图找出 ColB:

trying to do a sequence count in MS Access where the count sequence resets based on another field, so example below, trying to figure out ColB:

ColA ColB
4566 1
5677 1
5677 2
5677 3
8766 1
8766 2
1223 1

认为它可能与 DCount() 函数有关,不确定.非常感谢您的帮助...谢谢!

Think it might have something to do with the DCount() function, unsure. Would very much appreciate the help ... Thanks!

推荐答案

在 Access 查询中计算组序列号是相当常见的话题.需要唯一标识符字段,应提供自动编号.

Calculating a group sequence number in Access query is fairly common topic. Requires a unique identifier field, autonumber should serve.

使用 DCount():

Using DCount():

SELECT *, DCount("*", "table", "ColA=" & [ColA] & "AND ID<" & ID) + 1 AS GrpSeqFROM表;

或者使用相关子查询:

SELECT *, (SELECT Count(*) FROM table AS D WHERE D.ColA=table.ColA AND D.ID

在查询中计算的另一种方法是在带有排序和排序的报表上使用文本框的 RunningSum 属性.分组设置.

An alternative to calculating in query is to use RunningSum property of textbox on a Report with Sorting & Grouping settings.

这篇关于MS Access 重启编号序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆