排序表;然后分配顺序号码 [英] Sort Table; Then Assign Sequential Numbers

查看:53
本文介绍了排序表;然后分配顺序号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好:


我知道这很简单,但我似乎无法到达那里:


我需要通过文本字段(txtDescription)对表进行排序,然后将

顺序号分配给表中的SEQUENCE字段。


每次添加新记录,所有SEQUENCE#'必须重置。


重新编号将由EXPORT按钮触发。


什么'这是实现这个目标的最佳方法吗?一个更新查询,或一个循环在

VBA?


谢谢!


amy

===

解决方案

Amy,你可以简单地设计一个基于这个表的查询并按
$ b $排序b txtDescription。现在根据此查询设计报表。将未绑定的

文本框控件添加到报告的详细信息部分。从主菜单中选择文本框

和视图/属性。键入= 1作为控制源,

将运行总和设置为全部。现在它总是会为你计算它们。

所有你要做的就是导出报告。


-

Reggie


----------

" amywolfie" <是******* @ verizon.net>在消息中写道

news:33 ************************** @ posting.google.c om ...

大家好:

我知道这很简单,但我似乎无法到达那里:

我需要排序表格由文本字段(txtDescription)表示,然后将序号分配给表格中的SEQUENCE字段。

每次添加新记录时,必须重置所有SEQUENCE#' 。

重新编号将由EXPORT按钮触发。

实现此目的的最佳方法是什么?更新查询,或VBA中的循环?

谢谢!

amy
===



显然你知道关系表根据定义是无序的

所以他们没有记录号。作为非关系数据库表

有时会这样做。我猜对序列号的要求是使用你导出的数据的软件的要求


你可以创建一个用户定义函数按顺序返回下一个数字

所以你可以使用查询来做你想做的事情,但它看起来并不像

那么简单。 ..仔细检查会显示UDF可能被称为每个记录的多个

次,因此可能会跳过这些数字,除非您非常仔细地编码

以确保您对于相同的

记录,不要增加一次以上。


我认为它会更简单(也许更安全) )如果你使用带有排序的查询打开一个

记录集,并逐个更新

中的序列号。几乎可以肯定,这将比使用Query更慢的操作,但是为查询创建所需的UDF可能非常令人沮丧。


Larry Linson

Microsoft Access MVP


" amywolfie" <是******* @ verizon.net>在消息中写道

news:33 ************************** @ posting.google.c om ...

大家好:

我知道这很简单,但我似乎无法到达那里:

我需要排序表格由文本字段(txtDescription)表示,然后将序号分配给表格中的SEQUENCE字段。

每次添加新记录时,必须重置所有SEQUENCE#' 。

重新编号将由EXPORT按钮触发。

实现此目的的最佳方法是什么?更新查询,或VBA中的循环?

谢谢!

amy
===



Larry:


你绝对正确 - 序列顺序是

导出到DB2的要求。


有没有简单的替代手动输入,也许使用VBA?


谢谢!


amy

===


" Larry Linson" <博***** @ localhost.not>在消息新闻中写道:< gV **************** @ nwrddc01.gnilink.net> ...

显然你知道关系表是根据定义,无序
因此他们没有记录号码。作为非关系型数据库表有时会这样做。我猜对序列号的要求是对使用你导出的数据的软件的要求。

你可以创建一个用户定义的函数来返回下一个数字序列
所以你可以使用一个查询来做你想做的事情,但它似乎并不像看起来那么简单......仔细检查会显示UDF可能被称为多个
每个记录的次数,因此可能会跳过数字,除非您非常仔细地编码以确保您不会为同一个
记录增加多次。
如果你使用带有排序的查询打开一个
记录集,并且逐个更新每个记录中的序列号,我认为它会更简单(也可能更安全) 。几乎可以肯定,这比使用Query更慢,但是为查询创建所需的UDF会非常令人沮丧。

Larry Linson
Microsoft Access MVP

amywolfie <是******* @ verizon.net>在消息中写道
新闻:33 ************************** @ posting.google.c om ...

大家好:

我知道这很简单,但我似乎无法到达那里:

我需要按文字对表格进行排序字段(txtDescription),然后将序号分配给表格中的字段SEQUENCE。

每次添加新记录时,必须重置所有SEQUENCE#。

重新编号将由EXPORT按钮触发。

实现此目的的最佳方法是什么?更新查询,或VBA中的循环?
谢谢!

amy
===



Hi All:

I know this is simple, but I just can''t seem to get there:

I need to sort a table by a text field (txtDescription), then assign
sequential numbers to the field SEQUENCE in table.

Every time a new record is added, the all SEQUENCE #''s must be reset.

The re-numbering will be triggered by an EXPORT button.

What''s the best way to accomplish this? An update query, or a Loop in
VBA?

Thanks!

amy
===

解决方案

Amy, you could simply design a query based on this table and sort it by
txtDescription. Now design a report based on this query. Ad an unbound
text box control to the detail section of the report. Select the text box
and view/properties from the main menu. Type in =1 as the control source and
set the Running Sum to Over All. Now it will always count them for you.
All you have to do is export the report.

--
Reggie

----------
"amywolfie" <am*******@verizon.net> wrote in message
news:33**************************@posting.google.c om...

Hi All:

I know this is simple, but I just can''t seem to get there:

I need to sort a table by a text field (txtDescription), then assign
sequential numbers to the field SEQUENCE in table.

Every time a new record is added, the all SEQUENCE #''s must be reset.

The re-numbering will be triggered by an EXPORT button.

What''s the best way to accomplish this? An update query, or a Loop in
VBA?

Thanks!

amy
===



Obviously you are aware that relational tables are, by definition, unordered
so they don''t have a "record number" as non-relational database tables
sometimes do. I''d guess the requirement for a sequential number is a
requirement of the software that will use the data you export.

You can create a user defined function to return the next number in sequence
so you can use a query to do what you want, but it''s not nearly so simple as
it seems... close examination will show that the UDF may be called multiple
times for each record, so there may be skips in the numbers unless you code
very carefully to ensure you don''t increment more than once for the same
record.

I think it''ll be a good deal simpler (and perhaps safer, too) if you open a
recordset using a Query with the sort, and update the sequence numbers in
each record one by one. That will, almost certainly, be a slower operation
than using a Query, but creating the required UDF for the query can be very
frustrating.

Larry Linson
Microsoft Access MVP

"amywolfie" <am*******@verizon.net> wrote in message
news:33**************************@posting.google.c om...

Hi All:

I know this is simple, but I just can''t seem to get there:

I need to sort a table by a text field (txtDescription), then assign
sequential numbers to the field SEQUENCE in table.

Every time a new record is added, the all SEQUENCE #''s must be reset.

The re-numbering will be triggered by an EXPORT button.

What''s the best way to accomplish this? An update query, or a Loop in
VBA?

Thanks!

amy
===



Larry:

You are absolutely right -- the Sequence order is a requirement for an
export into DB2.

Is there a "simple" alternative to manual input, perhaps using VBA?

Thanks!

amy
===

"Larry Linson" <bo*****@localhost.not> wrote in message news:<gV****************@nwrddc01.gnilink.net>...

Obviously you are aware that relational tables are, by definition, unordered
so they don''t have a "record number" as non-relational database tables
sometimes do. I''d guess the requirement for a sequential number is a
requirement of the software that will use the data you export.

You can create a user defined function to return the next number in sequence
so you can use a query to do what you want, but it''s not nearly so simple as
it seems... close examination will show that the UDF may be called multiple
times for each record, so there may be skips in the numbers unless you code
very carefully to ensure you don''t increment more than once for the same
record.

I think it''ll be a good deal simpler (and perhaps safer, too) if you open a
recordset using a Query with the sort, and update the sequence numbers in
each record one by one. That will, almost certainly, be a slower operation
than using a Query, but creating the required UDF for the query can be very
frustrating.

Larry Linson
Microsoft Access MVP

"amywolfie" <am*******@verizon.net> wrote in message
news:33**************************@posting.google.c om...

Hi All:

I know this is simple, but I just can''t seem to get there:

I need to sort a table by a text field (txtDescription), then assign
sequential numbers to the field SEQUENCE in table.

Every time a new record is added, the all SEQUENCE #''s must be reset.

The re-numbering will be triggered by an EXPORT button.

What''s the best way to accomplish this? An update query, or a Loop in
VBA?

Thanks!

amy
===



这篇关于排序表;然后分配顺序号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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