确定表单中显示的第一个和最后一个记录

编程入门 行业动态 更新时间:2024-10-28 10:34:25
本文介绍了确定表单中显示的第一个和最后一个记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我将表单设置为单表单模式,通过下一步和上一页按钮,我可以循环访问表中的 记录。为了避免用户按下第一条记录上的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.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.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 therecords in a table via Next and Previous buttons. To avoid users pressingthe Previous button on the first record and the Next button on the lastrecord, I would like to disable one or both buttons when the first and/orlast record is displayed. I am not sure how to do this when theRecordSource is simply the table.I know that if the record source were a Recordset, I could use theAbsolutePosition and RecordCount properties, but in this case the recordsource is not a recordset.In another post, MacDermott drew my attention to the Recordset property of aform. According to the help manual, this property "returns the recordsetobject that provides the data being browsed in a form". I think that thismay be the answer to my problem, but I have not been able to get it to workin 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 IfIs using the form''s Recordset property the right way to go? If so, howwould I code it? (I have tried declaring a recordset variable and thenSetting its value to Me.Recordset, but this gives an error -- "Runtime error13. 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 ... 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... 零是第一个记录位置。。RecordCount -1是最后一个记录位置。 Zero is the first record position. .RecordCount -1 is the last record position.

更多推荐

确定表单中显示的第一个和最后一个记录

本文发布于:2023-10-18 06:10:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1503357.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:第一个   表单

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!