如何创建具有时间和日期戳在访问一个评论框 [英] How to create a comment box with time and date stamp in Access

查看:336
本文介绍了如何创建具有时间和日期戳在访问一个评论框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有Access 2010中所谓的联系人的模板。在窗体上有一个评论框,它下面的文本框和一个按钮。当你进入到文本框,然后点击该按钮将其添加文本批注框和时间/日期戳它。如果你做一遍它preserves在评论栏中旧文本,并添加下面的新文本。

There's a template in Access 2010 called Contacts. On the form there's a comment box, a text box below it and a button. When you enter text into the text box and click the button it adds the text to the comment box and time/date stamps it. If you do it again it preserves the old text in the comment box and adds the new text below it.

我是pretty的新的访问,但我希望能够将此功能添加到我的数据库。

I'm pretty new to access, but I would like to be able to add this feature to my database.

所以,我得在桌子上,形式以及输入文本框和按钮的窗体上的备注字段。有谁知道我在这里做的就是这个功能?

So I've got a Memo field on the table and form and an input text box and button on the form. Does anyone know what I do from here to get that functionality?

推荐答案

下面是如何做到这一点的另一个例子。我有以下形式:

Here is another example of how to do it. I have the following form:

通过以​​下code:

With the following code:

Private Sub cmdAppendComment_Click()
  If (IsNull(txtNewComment.value)) Then
    MsgBox ("Please enter a comment before clicking" & _
            "on the Append Comment button.")
    Exit Sub
  End If

  If (IsNull(txtComment.value)) Then
    txtComment.value = txtNewComment.value & " ~ " & _
               VBA.DateTime.Date & " ~ " & VBA.DateTime.Time
  Else
    txtComment.value = txtComment.value & _
               vbNewLine & vbNewLine & _
               txtNewComment.value & " ~ " & _
               VBA.DateTime.Date & " ~ " & VBA.DateTime.Time
  End If

  txtNewComment.value = ""
End Sub

这样做是验证新的注释有东西在里面。如果是这样,那么它会检查评价,看它是否已经包含的东西。如果确实如此,那么追加新的注释它,否则它只是赋予了新的注释吧。的日期和时间被添加到每个注释的结束

What this does is verify that the New Comment has something in it. If so, then it checks the Comment to see if it already contains something. If it does, then it appends the new comment to it, else it just assigns the new comment to it. The date and time is added to the end of each comment.

这篇关于如何创建具有时间和日期戳在访问一个评论框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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