数据库打开的次数 [英] Number of times database opened

查看:86
本文介绍了数据库打开的次数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天,


是否可以在表格上指明开放数据库打开/查看打开数据库的次数。


Tempy


***通过Developersdex发送 http://www.developersdex.com ***

Good day,

Is it possible to indicate on a form how many times the open database
has been opened/viewed.

Tempy

*** Sent via Developersdex http://www.developersdex.com ***

推荐答案

Tempy写道:
美好的一天,

是否可以在表格上指明打开/查看开放数据库的次数。

Tempy

***通过Developersdex http://www.developersdex.com 发送** *
Good day,

Is it possible to indicate on a form how many times the open database
has been opened/viewed.

Tempy

*** Sent via Developersdex http://www.developersdex.com ***



当然。创建一个表来存储计数器。在'OnOpen事件的形式

更新表格,将字段增加1.然后在表格上放置一个文本框

来显示该计数器。


Sure. Create a table to store a counter. In the form''s OnOpen event
update the table to increment the field by 1. Then put a text box on
the form to display that counter.


嗨沙拉,谢谢你的回复,但作为这个游戏的新手我是

不知道怎么做。你能解释一下。


提前致谢


Tempy


***通过Developersdex发送 http://www.developersdex.com ***
Hi Salad, thanks for the reply, but as a total newbie to this game i am
not sure how to do that. Could you explain.

Thanks in advance

Tempy

*** Sent via Developersdex http://www.developersdex.com ***


Tempy写道:
Tempy wrote:
嗨沙拉,谢谢你的回复,但作为这个游戏的新手,我不知道怎么做。您能否解释一下。

提前致谢

Tempy

***通过Developersdex发送 http://www.developersdex.com ***
Hi Salad, thanks for the reply, but as a total newbie to this game i am
not sure how to do that. Could you explain.

Thanks in advance

Tempy

*** Sent via Developersdex http://www.developersdex.com ***



有时我只需要一张桌子只有一个记录。字段

可能包含一些计数器和日期字段。所以...创建一个名为

计数器的表。创建一个名为FormOpen的字段,并将其设置为Long。保存

吧。请记住......仅限1条记录。并使默认值为0.打开

表并为其创建一个记录,并在计数器字段中输入0。


您可以使用UpdateQuery更新表单中的OnOpen事件

中的字段,但我会使用代码。在表单中,将文本框放到

表单上。在文本框的属性表中,单击其他选项卡

将其命名为FormOpenedThisManyTimes。


现在打开表单的属性表,并在事件中找到OnOpen 。

点击三点,选择Code,然后在Sub / EndSub之间输入以下代码



Dim rst作为DAO.Recordset

set rst = Currentdb.Openrecordset(" Counters",dbopensnapshot)

rst.Edit

rst!FormOpen = rst !FormOpen + 1

Me.FormOpenedThisManyTimes = rst!FormOpen

rst.Update

rst.close

set rst = Nothing


你也可以使用UpdateQuery增加计数器,然后使用

DLookUp()来获取值,但我认为一些代码会有所帮助你出去了

。突出显示您不理解的任何单词...前OpenRecordset和

按F1获取进一步帮助。


Sometimes I simply need a table that has only one record. The fields
may contain some counters and date fields. So...create a table called
Counters. Create a field called FormOpen and make it type Long. Save
it. Remember...1 record only. And make the default value 0. Open the
table and create a record for it and enter 0 in the counter field.

You could use an UpdateQuery to update the field in the OnOpen event of
the form, but I''ll use code. In the form, drop a text box onto the
form. In the property sheet for the textbox, click on the Other tab
call it FormOpenedThisManyTimes.

Now open the property sheet for the form and in Events find OnOpen.
Click on the triple dot, select Code, and enter the following code
between the Sub/EndSub

Dim rst As DAO.Recordset
set rst = Currentdb.Openrecordset("Counters",dbopensnapshot)
rst.Edit
rst!FormOpen = rst!FormOpen + 1
Me.FormOpenedThisManyTimes = rst!FormOpen
rst.Update
rst.close
set rst = Nothing

You could also use an UpdateQuery to increment the counter and then use
DLookUp() to get the value but I figured some code would help you out
too. Highlight any words you don''t understand...ex OpenRecordset and
press F1 for further help.


这篇关于数据库打开的次数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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