vba 如果在表单中的第一条/最后一条记录,如何禁用导航按钮
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15297128/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to disable navigation buttons if at the first/last record in a form
提问by Anton Hughes
In MS Access 2007 I want to be able to disable a navigation button on a form.
在 MS Access 2007 中,我希望能够禁用表单上的导航按钮。
Pseudo Code as follows
伪代码如下
If at the first record Then
Disable Previous button
ElseIf at the last record Then
Disable the Next button
I believe it has something to do with the Current event. Although I just not sure on the specific logic.
我相信这与当前事件有关。虽然我只是不确定具体的逻辑。
Any ideas?
有任何想法吗?
回答by Mike
Access disables the previous and next buttons on a normal navigation pane by default if your at the beginning or end of a recordset.
默认情况下,如果您位于记录集的开头或结尾,Access 会禁用普通导航窗格上的上一个和下一个按钮。
If your using custom navigation buttons then you can use
如果您使用自定义导航按钮,那么您可以使用
Private Sub Form_Current()
cmdPrevious.Enabled = Not (CurrentRecord = 1)
cmdNext.Enabled = Not (CurrentRecord = DCount(AnyField, RecordSource))
End Sub