current / total number of records in Txtbox

stu_c

Registered User.
Local time
Today, 08:09
Joined
Sep 20, 2007
Messages
494
Hi all
I have a text box I want to show the current record number and total records so it reads "1 of 10" etc, I have got it to work on my main form but cant on my sub form another any suggestions?
it seems to recognise the first record as 0, so it reads "0 of 10" when I go to the next record it will go "1 of 10" etc any suggestions why?

Both on main for and sub form code
Code:
Public Function udfRecords(f As Form)
' RECORD NUMBERS
With f
            udfRecords = .CurrentRecord & " of " & IIf(.NewRecord, .CurrentRecord, .Recordset.RecordCount)

End With
End Function

the text box field control source
Code:
=udfRecords([Form])

many thanks
 
why not create a Class out of it, see this demo and the code on each form/subform.
 

Attachments

Hello mate
thanks for the code, that genuinely am confused how that even works!, I cannot see how the boxes finds the data!
why not create a Class out of it, see this demo and the code on each form/subform.
 
Hi all
I have a text box I want to show the current record number and total records so it reads "1 of 10" etc, I have got it to work on my main form but cant on my sub form another any suggestions?
it seems to recognise the first record as 0, so it reads "0 of 10" when I go to the next record it will go "1 of 10" etc any suggestions why?

Both on main for and sub form code
Code:
Public Function udfRecords(f As Form)
' RECORD NUMBERS
With f
            udfRecords = .CurrentRecord & " of " & IIf(.NewRecord, .CurrentRecord, .Recordset.RecordCount)

End With
End Function

the text box field control source
Code:
=udfRecords([Form])

many thanks
I wonder if it has to do with the general context of the subform adding a new record? That gray area where it thinks it might be starting to create a new record, hence, it's something other than the first true record - and maybe calling it zero?
 

Users who are viewing this thread

Back
Top Bottom