怎样判断是不是最后一条记录

goldfish9 2003-02-24 03:26:42
我想让记录在最后一条的时候,出现一个对话框。可是我实现不了,总出现一条空的记录然后才弹出对话框。我的代码是这样的:
if rs.EOF = False Then
rs.MoveNext
Else
MsgBox "这是最后一条记录"
End If
...全文
51 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuzhiliang 2003-02-25
  • 打赏
  • 举报
回复
换一个方式,用rs.recordCount...
zhangyp 2003-02-25
  • 打赏
  • 举报
回复
rs.movefirst
do until rs.eof
rs.movenext
loop
rs.MovePrevious
MsgBox "这是最后一条记录"
enhydraboy 2003-02-25
  • 打赏
  • 举报
回复
为什么不在记录集的MoveComplete中做呢
Private Sub rsCommand1_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
If rsCommand1.EOF Then
MsgBox "Last Record"
If Not rsCommand1.BOF Then
rsCommand1.MovePrevious
End If
End If
End Sub


busisoft 2003-02-25
  • 打赏
  • 举报
回复
if rs.EOF = False Then

rs.MoveNext

if rs.EOF=True then MsgBox "这是最后一条记录"

End If
zw_yu 2003-02-25
  • 打赏
  • 举报
回复
if not rs.eof then
text1.text = rs("name")
rs.movenext
if rs.eof then
msgbox "last one"
end if
end if
Zedee 2003-02-25
  • 打赏
  • 举报
回复
可以用rs的当前记录计数方法(好像是rs.count记不清了)
和sql语句selcct count(字段名) from 表名 的结果比较,相等时说明是最后一条

不过这样做不太好,没必要的话还是用e4snake(小蛇) 的方法吧(到上一条记录的命令rs.moveprevious)
goldfish9 2003-02-25
  • 打赏
  • 举报
回复
能不能用一个值来表示最后一条记录的。比如:如果A=最后一条记录,则弹出对话框。
如果可以的话。那”最后一条记录“怎样表示的呢?
e4snake 2003-02-24
  • 打赏
  • 举报
回复
if rs.EOF = False Then
rs.MoveNext
Else
rs.MovePreviw '好像是这样写的,就是到上一条记录的命令
MsgBox "这是最后一条记录"
End If
enhydraboy 2003-02-24
  • 打赏
  • 举报
回复
You can not judge in the command_click event.
You must write code to judge in the rscordset_MoveComplete event


Private Sub rsCommand1_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
If rsCommand1.EOF Then
MsgBox "Last Record"
If Not rsCommand1.BOF Then
rsCommand1.MovePrevious
End If
End If
End Sub

when you bind recordset to your controls dynamicly, modify your recordset declaration code.

Private rs withevents as adodb.recordset
goldfish9 2003-02-24
  • 打赏
  • 举报
回复
不行的。
zw_yu 2003-02-24
  • 打赏
  • 举报
回复
do until rs.eof
rs.movenext
loop
MsgBox "这是最后一条记录"
zw_yu 2003-02-24
  • 打赏
  • 举报
回复
没做循环。很多记录的话应该做循环

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧