将提交的最后日期作为新条目的默认值 [英] Have the last date submitted be the default value for a new entry

查看:51
本文介绍了将提交的最后日期作为新条目的默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我是新手,我有一个简单的问题。我正在使用日期字段在MS Access 2007中编写表单,我希望该字段由输入的最后日期而不是今天的日期填充。我看到一个类似的问题已发布到您的论坛
有权访问召回表格中输入的最后日期

并实施解决方案:
"在您的日期字段属性中,在数据选项卡中,设置

默认值如下:= DLast(" [DateFieldName]"," Table Name")"


给了我一个随机日期,而不是输入的最后日期。我做错了什么?


我事先感谢你的帮助。


祝你好运,

米歇尔

Hello there,
I''m new to access and I have a simple question. I''m writing a form in MS Access 2007 with a date field, I''d like the field to be populated by the last date entered instead of today''s date. I saw that a similar question had be posted to your forum
Have access recall the last date entered in a form
and implemented the solution:
"In your Date Field Properties, under the Data Tab, set the
Default Value as follows: =DLast("[DateFieldName]","Table Name")"

The gave me a random date and not the last date entered. What am I doing wrong?

I thank you in advance for your help.

Best regards,
Michelle

推荐答案

帖子确实没问题米歇尔。事实上,对于一个新人来说,这是一份很好的工作。


你甚至没有在代码中失败,因为在链接线程中发布的建议不太正确(至少对你的要求而言)我可以稍后查看它是否适用于它所在的线程。您需要的是使用 DMax()而不是 DLast()


如果这样做,请告诉我们你的问题: - )
No problem with the post indeed Michelle. In fact a fine job for a newcomer.

You''re not even failing in the code, as the suggestion posted in the linked thread is not quite correct (for your requirement at least. I may check on it later to see if it holds for the thread it''s in). What you need there is to use DMax() instead of DLast().

Let us know if that sorts out the problem for you :-)


似乎我对你的要求的理解有误。我假设(可能是假设的)你想要所有先前输入的日期的最大值。如果您似乎更有可能想要最近输入的数据 - 最近进入系统的IE - 那么 DLast()可能对您有用(实际上它应该在大多数情况下)。你能举一个看似不正确的行为的例子吗?可能 DLast()只能在您根据输入记录的时间处理记录时按预期工作。我相信它实际上在正常情况下使用表中定义的PK,如果将此设置为自动编号字段,则可以正常工作,但如果将另一个字段(或多个字段)用作PK,则显然是随机的。


请填写我们的详细信息,以便我们提供更多帮助。
It seems I may have been mistaken in my understanding of your request. I had assumed (probably presumtuously) that you wanted the maximum of all previously entered dates. If, as seems more likely, you want the most recently entered data - IE that entered into the system most recently - then DLast() may work for you (indeed it should in most cases). Can you give an example of behaviour that appears to be incorrect? It may be that DLast() will only work as you''d expect when processing through the records based on when the record was entered. I believe it actually uses whatever is the defined PK of the table in normal circumstances, which would work correctly if you have this set as an AutoNumber field, but apparently randomly if another field (or fields) is used as the PK.

Please fill in the details for us in order that we can be of more help.


您好NeoPa,

谢谢非常感谢你的帮助(以及如此快速的答案)。 DMax()适用于此应用,因为最常见的日期将是最大值。我实现了它,效果很好。

对于我自己的教育 - 我想弄明白为什么 DLast()不起作用。对于这张表,我确实将PK作为自动编号。日期不是PK。通过使用 DLast()我获得了记录31的日期,即使有116条记录,其中116条是最近输入的记录。也许我的语法错了?

以下是我编写的适用于DMax的内容:
Hi NeoPa,
Thank you so much for your help with this (and such a fast answer). DMax() works well for this application since most frequently the date will be the maximum value. I implemented it and it works great.
For my own education though - I''d like to figure out why DLast() did not work. For this table I do have the PK as autonumber. The date is not the PK. By using DLast() I''m getting the date for record 31 even though there are 116 records, where 116 is the most recently entered record. Perhaps my syntax is wrong?
Here is what I wrote which works perfectly for DMax:
展开 | 选择 | Wrap < span class =codeDivider> | 行号


这篇关于将提交的最后日期作为新条目的默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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