确定表单中显示的第一个和最后一个记录 [英] Determining first and last records displayed in a form

查看:101
本文介绍了确定表单中显示的第一个和最后一个记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将表单设置为单表单模式,通过下一步和上一页按钮,我可以循环访问表中的

记录。为了避免用户按下第一条记录上的Previous按钮和最后一条

记录中的Next按钮,我想在第一条记录时禁用一个或两个按钮和/或

显示最后一条记录。当

RecordSource只是表时,我不知道怎么做。


我知道如果记录源是Recordset,我可以使用

AbsolutePosition和RecordCount属性,但在这种情况下,记录

来源不是记录集。


在另一篇文章中, MacDermott引起了我对

表格的Recordset属性的注意。根据帮助手册,该属性返回记录集

对象,该对象提供以形式浏览的数据。我认为这个

可能是我的问题的答案,但我无法让它在ADO环境中工作




我正在为Current事件寻找的代码类型是:


如果< recordset> .AbsolutePosition = 1那么

我!btnPrev.Enabled = False

否则

我!btnPrev.Enabled = True

结束如果

如果< recordset> .AbsolutePosition =< recordset> .RecordCount Then

Me!btnNext.Enabled = False

Else

Me!btnNext。 Enabled = True

结束如果


使用表格的'Recordset属性'是正确的方法吗?如果是这样,我将如何编码
? (我已经尝试声明一个记录集变量然后

将其值设置为Me.Recordset,但这会产生错误 - 运行时错误

13.不匹配。 )


或者有更好的方法吗?


任何帮助表示感谢。

-

干杯,

Lyn。

I have a form set to Single Form mode with which I can cycle through the
records in a table via Next and Previous buttons. To avoid users pressing
the Previous button on the first record and the Next button on the last
record, I would like to disable one or both buttons when the first and/or
last record is displayed. I am not sure how to do this when the
RecordSource is simply the table.

I know that if the record source were a Recordset, I could use the
AbsolutePosition and RecordCount properties, but in this case the record
source is not a recordset.

In another post, MacDermott drew my attention to the Recordset property of a
form. According to the help manual, this property "returns the recordset
object that provides the data being browsed in a form". I think that this
may be the answer to my problem, but I have not been able to get it to work
in the ADO environment.

The sort of code I am looking at for the Current event is:

If <recordset>.AbsolutePosition = 1 Then
Me!btnPrev.Enabled = False
Else
Me!btnPrev.Enabled = True
End If
If <recordset>.AbsolutePosition = <recordset>.RecordCount Then
Me!btnNext.Enabled = False
Else
Me!btnNext.Enabled = True
End If

Is using the form''s Recordset property the right way to go? If so, how
would I code it? (I have tried declaring a recordset variable and then
Setting its value to Me.Recordset, but this gives an error -- "Runtime error
13. Mismatch".)

Or is there a better approach than this?

Any help appreciated.
--
Cheers,
Lyn.

推荐答案

2005年1月24日星期一23:50:19 +1100,Lyn < lh ****** @ ihug.com.au>

写道:


更好的方法可能是使用内置导航按钮。


如果你有一个非常好的理由你需要运行自己的按钮,我将建议表格的'RecordsetClone属性:

set rs = me.recordsetclone

rs.bookmark = me.bookmark''sync rs with form

btnPrev.enabled =(rs.absoluteposition> 1)

设rs =没有


-Tom。

On Mon, 24 Jan 2005 23:50:19 +1100, "Lyn" <lh******@ihug.com.au>
wrote:

The better approach may be to use the built-in navigation buttons.

If you have a REALLY good reason you need to run your own buttons, I
would suggest the form''s RecordsetClone property:
set rs=me.recordsetclone
rs.bookmark=me.bookmark '' sync rs with form
btnPrev.enabled = (rs.absoluteposition>1)
set rs=nothing

-Tom.

我有一个表单集单表格模式,我可以通过下一个和上一个按钮循环浏览表格中的
记录。为了避免用户按下第一个记录上的上一个按钮和最后一个记录上的下一个按钮,我想在第一个和/或
最后一个记录时禁用一个或两个按钮。显示。当
RecordSource只是表格时,我不知道怎么做。

我知道如果记录源是Recordset,我可以使用
AbsolutePosition和RecordCount属性,但在这种情况下,记录
源不是记录集。

在另一篇文章中,MacDermott引起了我对
表单的Recordset属性的注意。根据帮助手册,该属性返回记录集
对象,该对象提供以表格形式浏览的数据。我认为这可能是我的问题的答案,但我无法在ADO环境中使用它。

我的代码类型寻找当前事件的是:

如果< recordset> .AbsolutePosition = 1那么
我!btnPrev.Enabled = False
否则
我!btnPrev。 Enabled = True
结束如果
如果< recordset> .AbsolutePosition =< recordset> .RecordCount那么
我!btnNext.Enabled = False
否则
我! btnNext.Enabled = True
结束如果

使用表单'的Recordset属性是正确的方法吗?如果是这样,我将如何编码呢? (我已经尝试声明一个记录集变量,然后将其值设置为Me.Recordset,但这会产生错误 - 运行时错误
13.不匹配。)
或者有更好的方法吗?

任何帮助表示赞赏。
I have a form set to Single Form mode with which I can cycle through the
records in a table via Next and Previous buttons. To avoid users pressing
the Previous button on the first record and the Next button on the last
record, I would like to disable one or both buttons when the first and/or
last record is displayed. I am not sure how to do this when the
RecordSource is simply the table.

I know that if the record source were a Recordset, I could use the
AbsolutePosition and RecordCount properties, but in this case the record
source is not a recordset.

In another post, MacDermott drew my attention to the Recordset property of a
form. According to the help manual, this property "returns the recordset
object that provides the data being browsed in a form". I think that this
may be the answer to my problem, but I have not been able to get it to work
in the ADO environment.

The sort of code I am looking at for the Current event is:

If <recordset>.AbsolutePosition = 1 Then
Me!btnPrev.Enabled = False
Else
Me!btnPrev.Enabled = True
End If
If <recordset>.AbsolutePosition = <recordset>.RecordCount Then
Me!btnNext.Enabled = False
Else
Me!btnNext.Enabled = True
End If

Is using the form''s Recordset property the right way to go? If so, how
would I code it? (I have tried declaring a recordset variable and then
Setting its value to Me.Recordset, but this gives an error -- "Runtime error
13. Mismatch".)

Or is there a better approach than this?

Any help appreciated.






Lyn写道:
我有一个表单设置为单表单模式,我可以通过下一个和上一个按钮循环浏览表格中的
记录。为了避免用户按下第一个记录上的上一个按钮和最后一个记录上的下一个按钮,我想在第一个和/或
最后一个记录时禁用一个或两个按钮。显示。当
RecordSource只是表格时,我不知道怎么做。

我知道如果记录源是Recordset,我可以使用
AbsolutePosition和RecordCount属性,但在这种情况下,记录
源不是记录集。

在另一篇文章中,MacDermott引起了我对
表单的Recordset属性的注意。根据帮助手册,该属性返回记录集
对象,该对象提供以表格形式浏览的数据。我认为这可能是我的问题的答案,但我无法在ADO环境中使用它。

我的代码类型寻找当前事件的是:

如果< recordset> .AbsolutePosition = 1那么
我!btnPrev.Enabled = False
否则
我!btnPrev。 Enabled = True
结束如果
如果< recordset> .AbsolutePosition =< recordset> .RecordCount那么
我!btnNext.Enabled = False
否则
我! btnNext.Enabled = True
结束如果

使用表单'的Recordset属性是正确的方法吗?如果是这样,我将如何编码呢? (我已经尝试声明一个记录集变量,然后将其值设置为Me.Recordset,但这会产生错误 - 运行时错误
13.不匹配。)
I have a form set to Single Form mode with which I can cycle through the
records in a table via Next and Previous buttons. To avoid users pressing
the Previous button on the first record and the Next button on the last
record, I would like to disable one or both buttons when the first and/or
last record is displayed. I am not sure how to do this when the
RecordSource is simply the table.

I know that if the record source were a Recordset, I could use the
AbsolutePosition and RecordCount properties, but in this case the record
source is not a recordset.

In another post, MacDermott drew my attention to the Recordset property of a
form. According to the help manual, this property "returns the recordset
object that provides the data being browsed in a form". I think that this
may be the answer to my problem, but I have not been able to get it to work
in the ADO environment.

The sort of code I am looking at for the Current event is:

If <recordset>.AbsolutePosition = 1 Then
Me!btnPrev.Enabled = False
Else
Me!btnPrev.Enabled = True
End If
If <recordset>.AbsolutePosition = <recordset>.RecordCount Then
Me!btnNext.Enabled = False
Else
Me!btnNext.Enabled = True
End If

Is using the form''s Recordset property the right way to go? If so, how
would I code it? (I have tried declaring a recordset variable and then
Setting its value to Me.Recordset, but this gives an error -- "Runtime error
13. Mismatch".)




零是第一个记录位置。

..RecordCount -1是最后一个记录位置。



Zero is the first record position.
..RecordCount -1 is the last record position.

我认为这适用于DAO。我正在使用ADO并根据帮助文件,

第一条记录是1而-1表示adPosUnknown。非常混乱!


-

干杯,

Lyn。


" ; RKC" < rk*@rochester.yabba.dabba.do.rr.bomb>在消息中写道

news:%_ ******************* @ twister.nyroc.rr.com ...
I think that applies to DAO. I am using ADO and according to the Help file,
the first record is 1 and -1 means adPosUnknown. Very confusing!

--
Cheers,
Lyn.

"rkc" <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in message
news:%_*******************@twister.nyroc.rr.com...
零是第一个记录位置。
。RecordCount -1是最后一个记录位置。
Zero is the first record position.
.RecordCount -1 is the last record position.



这篇关于确定表单中显示的第一个和最后一个记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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