生成表查询中的简单自动编号查询 [英] Simple AutoNumber query in Make-Table Queries

查看:87
本文介绍了生成表查询中的简单自动编号查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


关于一个函数的快速问题,肯定应该可以在Access中的生成表查询中实现。我想知道是否有可能非常简单地有一个字段,将结果表中的行从1行编号为行n,无论该表中的数据是什么。


在我的例子中,我有一个保险经纪人列表和一个金额列表(称为DollarDaysGBP)作为我查询的结果字段。我希望另一个字段计数1,2,3等。无论我拖入查询的哪个字段,或者我如何对它们进行排序,我希望自动编号字段始终为1,2,3等。

>
以下是我查询的源/ SQL代码。我发现一些在线代码可以工作,但需要链接到另一个字段以获得自动编号列表。如果可能的话,我希望我的Autonumber字段是独立的。


我不是一个熟练的Access用户,但这似乎很多人可能会需要,并广泛搜索帮助菜单和这个论坛没有产生任何结果。任何帮助将不胜感激。


谢谢

Ian

Hi all,

A quick question about a function which surely should be possible in a Make-Table Query in Access. I wonder if it''s possible to very simply have a field that numbers the rows in the resultant table from 1 to row n, no matter what the data in that table is.

In my example, I have a list of insurance brokers and a list of amounts (called DollarDaysGBP) as the result fields of my query. I want another field counting 1, 2, 3 etc. No matter what fields I drag into my query, or how I sort them, I want the Autonumber field to always be 1, 2, 3 etc.

Below is the source/SQL code of my query. I have found one bit of code online that works, but needs to be linked to another field to get an Autonumber list. I''d like my Autonumber field to be independent, if possible.

I''m not a proficient user of Access by any means but this seems something that a lot of people might need, and searching extensively the Help menus and this forum has yielded no results. Any help would be much appreciated.

Thanks
Ian

推荐答案

你省略了SQL对于你的疑问。

我从概念上不知道答案,但我对这个问题很感兴趣。我会做一个心理记录,寻找一些东西。它应该可用我想。
You omitted the SQL for your query.
I don''t know the answer conceptually, but I''m interested in the question. I''ll make a mental note to look out for something. It should be available I would think.


查找了SELECT ... INTO(Make Table)查询的一般语法,似乎毕竟不支持此功能:(抱歉。
Having looked up the general syntax for a SELECT ... INTO (Make Table) query, it seems that this feature is not supported after all :( Sorry.



查找SELECT ... INTO(Make Table)查询的一般语法后,似乎此功能是毕竟不支持:(对不起。
Having looked up the general syntax for a SELECT ... INTO (Make Table) query, it seems that this feature is not supported after all :( Sorry.



NeoPa:

这里有一个小小的Off-The-Wall技术,我每次都会使用它想要查询结果从1开始顺序编号,无论任何字段或字段上的任何排序顺序,字段数等等。这有点激进,但似乎没有其他方法可以达到相同的结果。请看一下让我知道你的想法。这个代码必须在执行Query之前运行,它还涉及将[Counter]字段添加到底层表,然后用这个([Counter])执行Query作为第1个列。它根据您想要按顺序编号的查询创建一个Recordset,并将增量值写入从位置1开始的[Counter]字段。我确信它可以改进 - 我只知道它有效。

NeoPa:
Here is a little Off-The-Wall technique that I always use whenever I want Query results to be numbered sequentially starting from 1 regardless of any Sort Order on any Field or Fields, number of Fields, etc. It is a little radical but there seems to be no other way to achieve the same result. Please look at it and let me know what you think. This code must be run prior to executing the Query and it also involves adding a [Counter] Field to the underlying Table then executing the Query with this ([Counter]) as the very 1st Column. It creates a Recordset based on the very Query that you want to sequentially number and writes the incremental values to the [Counter] Field starting at position 1. I''m sure that it can be improved - I just know that it works.

展开 | 选择 | Wrap | 行号


这篇关于生成表查询中的简单自动编号查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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