MS Access 将行信息转换为列信息
我花了几个小时试图解决这个问题。这是一家制造工厂。
工厂车间的一个人使用计算机系统记录他们在不同机器上的活动,该系统产生如下数据:
Empnbr Datestamp Shift Machnbr Time
00090 6/30/2010 1 0354 11:10
00090 6/30/2010 1 S 12:00
00098 6/30/2010 1 0920 7:00
00098 6/30/2010 1 0143 7:30
00098 6/30/2010 1 S 15:00
00101 6/30/2010 1 0920 7:00
00101 6/30/2010 1 0247 7:30
00101 6/30/2010 1 0147 7:40
00101 6/30/2010 1 S 15:00
00107 6/30/2010 1 0585 7:00
00107 6/30/2010 1 0143 12:00
00107 6/30/2010 1 S 15:00
00109 6/30/2010 1 0920 7:00
00109 6/30/2010 1 0154 7:30
00109 6/30/2010 1 0154 9:00
00109 6/30/2010 1 0154 9:43
00109 6/30/2010 1 0254 10:49
00109 6/30/2010 1 0154 12:30
00109 6/30/2010 1 S 15:00
00111 6/30/2010 1 0591 5:00
00111 6/30/2010 1 S 17:00
00114 6/30/2010 2 0585 15:00
00114 6/30/2010 2 S 23:00
我正在尝试编写的报告需要这种形式的信息
Empnbr Datestamp Shift Time Start Time End Machine
这将允许我计算在每个机器上花费的时间每人每天机器。基本上,Access 需要查看员工编号、日期戳和班次,并在第一次看到时进行记录。然后需要获取下一次看到的时间,并将该时间归因于第一次输入的机器。这种情况会持续发生,直到 Access 遇到计算机“S”(表示注销)。
现在该服用一些 Advil 来治疗头痛了——感谢您的帮助!
I've spent hours trying to figure this one out. This is for a manufacturing plant.
A person on the plant floor logs their activities on different machines using a computer system which produces data like this:
Empnbr Datestamp Shift Machnbr Time
00090 6/30/2010 1 0354 11:10
00090 6/30/2010 1 S 12:00
00098 6/30/2010 1 0920 7:00
00098 6/30/2010 1 0143 7:30
00098 6/30/2010 1 S 15:00
00101 6/30/2010 1 0920 7:00
00101 6/30/2010 1 0247 7:30
00101 6/30/2010 1 0147 7:40
00101 6/30/2010 1 S 15:00
00107 6/30/2010 1 0585 7:00
00107 6/30/2010 1 0143 12:00
00107 6/30/2010 1 S 15:00
00109 6/30/2010 1 0920 7:00
00109 6/30/2010 1 0154 7:30
00109 6/30/2010 1 0154 9:00
00109 6/30/2010 1 0154 9:43
00109 6/30/2010 1 0254 10:49
00109 6/30/2010 1 0154 12:30
00109 6/30/2010 1 S 15:00
00111 6/30/2010 1 0591 5:00
00111 6/30/2010 1 S 17:00
00114 6/30/2010 2 0585 15:00
00114 6/30/2010 2 S 23:00
The report I'm trying to write needs the information in such a form
Empnbr Datestamp Shift Time Start Time End Machine
This will allow me to calculate the amount of time spent on each machine per person per day. Basically, Access needs to see an employee number, datestamp, and shift and take the first time it sees. Then needs to take the next time it sees and attribute that time to the machine on the first entry. This continues to happen until Access comes across a machine "S" which means signout.
Now time to take some Advil for this headache -- thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会使用临时表。当您想要显示报告时,请使用 VBA 代码来遍历输入表、构建报告数据并填充临时表。然后使用临时表中的数据显示您的报告。填充报告表的函数如下所示:
I would use a temporary table. When you want to display the report use VBA code to go through your input table, build the report data, and populate the temporary table. Then display your report using the data in the temporary table. The function to populate the reporting table would look something like this:
有什么理由不适合分组查询吗?例如:
编辑重新评论
也许:
Is there any reason why a grouping query would not suit? For example:
EDIT re comment
Perhaps: