|
我想在窗体(窗体名字叫人员信息表)中显示“第n条记录 共m条记录
建立了一个函数:
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"
Case Else
strTmp = "#" & Error
Resume RecordNumber_Exit
End Select
End Function
并在主窗体中插入一个文本框控件,在控件来源中写:=RecordNumber("第",Forms!人员信息表)
但就是实现不了,请各位帮忙看看是哪里做错了?谢谢! |
|