Access开发培训
网站公告
·Access专家课堂QQ群号:151711184    ·Access快速开发平台下载地址及教程    ·欢迎加入Access专家课堂微信群!    ·如何快速搜索本站文章|示例|资料    
您的位置: 首页 > 技术文章 > Access数据库-模块/函数/VBA

2种在窗体上显示记录数的函数

时 间:2008-07-01 16:27:19
作 者:十段   ID:563  城市:上海
摘 要:2种在窗体上显示记录数的函数
正 文:

NO. 1:
=RecordNumber("第",me)'me指当前窗体

Function RecordNumber(pstrPreFix As String, pfrm As Form) As String
On Error GoTo RecordNumber_Err
Dim rst
Dim lngNumRecords As Long
Dim lngCurrentRecord As Long
Dim strTmp As String

Set rst = pfrm.RecordsetClone
rst.MoveLast
rst.Bookmark = pfrm.Bookmark
lngNumRecords = rst.RecordCount
lngCurrentRecord = rst.AbsolutePosition + 1
strTmp = pstrPreFix & " " & lngCurrentRecord & " 页," & " 共 " & lngNumRecords & " " & "页"
RecordNumber_Exit:
On Error Resume Next
RecordNumber = strTmp
rst.Close
Set rst = Nothing
Exit Function
RecordNumber_Err:
Select Case Err
Case 3021
strTmp = "New Record"
Resume RecordNumber_Exit
Case Else
strTmp = "#" & Error
Resume RecordNumber_Exit
End Select
End Function

NO. 2
Function RecordNum(frmData As Form) As String
On Error Resume Next
    frmData.RecordsetClone.MoveLast
    DoEvents
    If frmData.NewRecord = True Then
        RecordNum = "新记录" & "/共" & frmData.RecordsetClone.RecordCount & "条"
    Else
        RecordNum = "记录" & frmData.CurrentRecord & "/共" & frmData.RecordsetClone.RecordCount & "条"
    End If
End Function



Access软件网官方交流QQ群 (群号:54525238)       Access源码网店

常见问答:

技术分类:

相关资源:

专栏作家

关于我们 | 服务条款 | 在线投稿 | 友情链接 | 网站统计 | 网站帮助