在Access中如何显示窗体“第n条记录 共m条记录”的函数?
调用方法:=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
页:
[1]