研发埠
标题:
在Access中如何显示窗体“第n条记录 共m条记录”的函数?
[打印本页]
作者:
邓英超
时间:
2013-7-4 10:37
标题:
在Access中如何显示窗体“第n条记录 共m条记录”的函数?
作者:
淡写轻描
时间:
2013-7-4 11:01
调用方法:=RecordNumber("第",me)'me指当前窗体可在文框的控件来源中写:=RecordNumber("第",forms!当前窗体名) 在代码的窗体成为当前事件中写:me.文本框=RecordNumber("第", Me)结果虽相同,但在代码中的要快!但是,在代码的窗体成为当前事件中写:Me.标签.Caption = RecordNumber("第", Me)用标签,速度明显要比前两个用法还要快!Function RecordNumber(pstrPreFix As String,pfrm As Form) As StringOn Error GoTo RecordNumber_ErrDim rstDim lngNumRecords As LongDim lngCurrentRecord As LongDim strTmp As String Set rst = pfrm.RecordsetClonerst.MoveLastrst.Bookmark = pfrm.BookmarklngNumRecords = rst.RecordCountlngCurrentRecord = rst.AbsolutePosition + 1strTmp = pstrPreFix & " "& lngCurrentRecord & " 页," & "共 " & lngNumRecords & " " & "页"RecordNumber_Exit:On Error Resume NextRecordNumber = strTmprst.CloseSet rst = NothingExit FunctionRecordNumber_Err:Select Case ErrCase 3021strTmp = "New Record"Resume RecordNumber_ExitCase ElsestrTmp = "#" & ErrorResume RecordNumber_ExitEnd SelectEnd Function
欢迎光临 研发埠 (http://bbs.yanfabu.com/)
Powered by Discuz! X3.2