基于字段值的增量和记录创建 [英] Increment and record creation based on field value

查看:96
本文介绍了基于字段值的增量和记录创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Access 2003

Access 2003

最终,我需要创建一个用于打印标签样品ID,x的x的jar"的报告.

Ultimately I need to create a report for printing labels "Sample ID, Jar x of x".

我的桌子上有样品ID和罐数.是否可以创建一个查询,该查询为我提供3个字段:样品ID,广口瓶编号,广口瓶数量-广口瓶编号根据广口瓶数量创建增量记录吗?

My table has Sample ID and Number of Jars. Is it possible to create a query that gives me 3 fields: Sample ID, Jar Number, Number of Jars - where the Jar Number creates records in increments based on Number of Jars?

  Query:  Sample ID - Jar Number - Number of Jars
          Sample 1    1            4
          Sample 1    2            4
          Sample 1    3            4
          Sample 1    4            4
          Sample 2    1            2
          Sample 2    2            2

表信息为:

  Table:  Sample ID - Number of Jars
          Sample 1    4
          Sample 2    2

我要避免为每个罐子创建一个表记录.

I want to avoid creating a table record for each jar.

推荐答案

您可以利用数字表:

SELECT samples.[Sample ID], 
       samples.[Number of Jars], 
       Numbers.Number AS [Jar Number] INTO NewSamples
FROM samples, Numbers
WHERE Numbers.Number<=[Number of Jars]

样本是您当前表的名称.

Samples is the name of your current table.

数字表包含1到整数之间的整数,这是您可以从罐子中获得的最高数字,例如100.

The numbers table contains integers between 1 and what ever number is the highest number you can get for jars, say 100.

如果您已经有一个从零开始的数字表,则可以使用:

If you already have a zero-based numbers table, you could use:

WHERE Numbers.Number Between 1 And [Number of Jars]

这篇关于基于字段值的增量和记录创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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