如何让ACCESS在每条记录上加上DAT / TIME标记? [英] How do I get ACCESS to put a DAT/TIME stamp on each record?

查看:115
本文介绍了如何让ACCESS在每条记录上加上DAT / TIME标记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用条形码阅读器创建一个非常简单的数据库来输入ID号和位置。我希望ACCESS自动填充带有日期/时间戳的日期/时间字段,以记录创建记录的时间。我将如何实现这一目标?

I am creating a very simple database using barcode readers to input an ID number and location. I want ACCESS to automatically populate a date/time field with a date/time stamp to record when the record was created. How would I achieve this?

推荐答案

据我所知,Access没有内置支持。如果你只需要保留创建它的时间,它就相当简单。

在你的表中添加一个字段,dt_Created,使它成为日期/时间类型,在默认值中,写入 = NOW()"或者Now()(我不记得是否需要=)


希望对你有用,如果你有的话更多问题再次出现!


欢迎来到 BYTES
As far as I know, Access has no built-in support for this. If you only need to keep time of when its created, its rather simple.

Add a field to your table, dt_Created, make it date/time type, in the default value, write "=NOW()" or "Now()" (I can''t remember if the "=" is required)

Hope that works for you, if you have more questions come again!

Welcome to BYTES


将保存您的记录应该有两个附加字段日期 &安培; "时间" (选择不同的名称,因为这些是保留的访问名称)。


现在根据表创建一个表单。在设计视图中打开它并将宏附加到On Load事件( - > Property Sheet - > Even ---> on Load)。使用SetValue操作(您必须显示所有宏操作以查看此操作)。现在,在表单上键入日期字段的名称,并在Date()中键入作为表达。如果该字段被称为DateA,则

项目:[日期]

表达式:日期()


对于时间字段,假设该字段的名称是TimeA,那么

项目:[TimeA]

表达式:时间()。


当然你可以将这个宏附加到任何其他事件,比如更新一个字段......等等。


或者你可以使用VB,再次将此代码附加到你想要的事件上,加载,专注于一个字段,......等
The table which will save your records should have two additional fields "Date" & "Time" (choose different names as these are reserved Access names).

Now create a form based on the table. Open it in design view and Append a macro to the On Load Event (--> Property Sheet --> Even ---> on Load). Use the "SetValue" Action (you must show all macro actions to see this one). Now type the name of the date field on the form and "Date()" as the expression. If the field is called DateA, then
Item: [Date]
Expression: Date()

For the time field, suppose the name of the field is TimeA, then
Item: [TimeA]
Expression: Time ().

Of course you can attach this macro to any other event like after updating one field ...etc.

Alternatively you can use VB, again attach this code to the event you desire, on load, focus on a field,...etc

展开 | 选择 | Wrap | 行号


错过 Ť他认为你可能需要他们在一个领域。如果是这种情况,只需按照相同的步骤操作,并在表达式字段中使用SmileyOne声明的现在()


VB:
Missed the part you might need them both in one field. If this is the case, just follow the same steps and use as SmileyOne stated Now() in the expression field.

VB:
展开 | 选择 | Wrap | 行号


这篇关于如何让ACCESS在每条记录上加上DAT / TIME标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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