DMax函数没有响应粘贴的记录 [英] DMax Function Not Responding on Pasted Records

查看:52
本文介绍了DMax函数没有响应粘贴的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我将ID字段设置为Dmax函数,以在MainForm的BeforeInsert上生成下一个记录号(在datasheetView上)。如果逐个输入记录,它可以正常工作,但是当你一次粘贴记录时,你会在ID字段中以类似的ID结束(不按预期递增)。

我的用户总是在寻找用于从某个地方粘贴记录的快捷方式!

这是代码

Hi all!
I set ID field to Dmax function to generate the next record number at the BeforeInsert of the MainForm(on datasheetView). It Works fine if the records is entered one by one, but when you paste the Records at once, you endup with similar ID at the ID field (not incremented as expected).
My users are always looking for shortcuts to paste records from somewhere!
Here is the Code

展开 | 选择 | Wrap | 行号

推荐答案

我猜是将所有记录加在一起被视为单个事务。也就是说,在添加所有记录并提交事务之前,这些记录的添加都不可见。


您需要在代码中处理此事。类似下面的内容可能有效:
I would guess that the addition of all the records together is treated as a single transaction. That is to say that none of the additions of those records will be visible until all of them have been added and the transaction committed.

You will need to handle this in your code. Something like the following may work :
展开 | 选择 | Wrap | 行号


我试图粘贴代码,但它提供了ODD值计数

1 3 5 7 9 ....

和不正常计数为1 2 3 4 5 6 .....
I have tried to paste the code but it gives ODD Value Counting
1 3 5 7 9 ....
and not normal Counting as 1 2 3 4 5 6 .....


非常奇怪。我在我敲了一个系统上测试了它,我不仅注意到在代码中设置了Me.ID的vale之后再次触发了表单的BeforeInsert事件(从而导致了双倍增量),而且ID的值从未在表单或记录中实际更改过。


但是,通过稍微改动,我能够生成满足要求的例程:

Very strange. I tested it out on a system I knocked up and not only did I notice that the BeforeInsert event for the form was triggered again after the vale of Me.ID was set in the code (thus causing the double increment), but also that the value of ID was never actually changed either on the form or in the record.

With a minor change however, I was able to produce a routine that did what was required :

展开 | 选择 | Wrap | 行号


这篇关于DMax函数没有响应粘贴的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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