I'm trying to display the record numbers on a form. For example (Record 1 of 9). I've created a module with the below code. Then I set my Control Source to =hpFormRecCount() on the text box. This produces the following error "The expression you entered has a function containing the wrong number of arguments" Any ideas what I'm doing wrong? Thanks.
Bill
'Building a string containg 'curent record' of 'num of
records' on a form.
Function hpFormRecCount(Form As Form) As String
Dim lngRecPos As Long
Dim lngRecCount As Long
Dim strTemp As String
If Form.NewRecord And Form.RecordsetClone.BOF Then
strTemp = "1 of 1"
Exit Function
ElseIf Form.NewRecord And Not Form.RecordsetClone.BOF Then
lngRecPos = Form.CurrentRecord
lngRecCount = (Form.RecordsetClone.RecordCount + 1)
Else
Form.RecordsetClone.MoveLast
lngRecPos = Form.CurrentRecord
lngRecCount = Form.RecordsetClone.RecordCount
End If
strTemp = str(lngRecPos) & " of " & str(lngRecCount)
hpFormRecCount = strTemp
End Function
Bill
'Building a string containg 'curent record' of 'num of
records' on a form.
Function hpFormRecCount(Form As Form) As String
Dim lngRecPos As Long
Dim lngRecCount As Long
Dim strTemp As String
If Form.NewRecord And Form.RecordsetClone.BOF Then
strTemp = "1 of 1"
Exit Function
ElseIf Form.NewRecord And Not Form.RecordsetClone.BOF Then
lngRecPos = Form.CurrentRecord
lngRecCount = (Form.RecordsetClone.RecordCount + 1)
Else
Form.RecordsetClone.MoveLast
lngRecPos = Form.CurrentRecord
lngRecCount = Form.RecordsetClone.RecordCount
End If
strTemp = str(lngRecPos) & " of " & str(lngRecCount)
hpFormRecCount = strTemp
End Function