G
gagecres
I would like to add my own record counter, like "Record # of #", to my form.
How can I do this?
How can I do this?
BruceM via AccessMonster.com said:Try checking the RecordCount of RecordsetClone, and breaking up the code a
little:
Debug.Print Me.RecordsetClone.RecordCount
Me.RecordsetClone.MoveLast
Me.txt_Rec_Count = Me.CurrentRecord & " of " & Me.RecordsetClone.RecordCount
& " line(s)"
Rather than using the Load event, perhaps something like this:
Dim lngCount as Long
Dim strCount as String
lngCount = Me.RecordsetClone.RecordCount
If lngCount = 0 Then
strCount = "First Record"
Else
strCount = Me.CurrentRecord & " of " & Me.RecordsetClone.RecordCount & "
line(s)"
End If
Me.txt_Rec_Count = strCount
Here is the code I am using:
With Me.RecordsetClone
.MoveLast
Me.txt_Rec_Count.Value = Me.CurrentRecord & " of " & .RecordCount &
" line(s)"
End With
Also, I commented out the OnLoad lines
[quoted text clipped - 60 lines]Please post the exactly the code you are using here... And if you have no
reason for the DoCmd.GoToRecord lines, remove them from the On_Load event.
--
Message posted via AccessMonster.com
.
gagecres said:This did the trick. Thanks a lot!
BruceM via AccessMonster.com said:Try checking the RecordCount of RecordsetClone, and breaking up the code a
little:
Debug.Print Me.RecordsetClone.RecordCount
Me.RecordsetClone.MoveLast
Me.txt_Rec_Count = Me.CurrentRecord & " of " & Me.RecordsetClone.RecordCount
& " line(s)"
Rather than using the Load event, perhaps something like this:
Dim lngCount as Long
Dim strCount as String
lngCount = Me.RecordsetClone.RecordCount
If lngCount = 0 Then
strCount = "First Record"
Else
strCount = Me.CurrentRecord & " of " & Me.RecordsetClone.RecordCount & "
line(s)"
End If
Me.txt_Rec_Count = strCount
Here is the code I am using:
With Me.RecordsetClone
.MoveLast
Me.txt_Rec_Count.Value = Me.CurrentRecord & " of " & .RecordCount &
" line(s)"
End With
Also, I commented out the OnLoad lines
Please post the exactly the code you are using here... And if you have no
reason for the DoCmd.GoToRecord lines, remove them from the On_Load event.
[quoted text clipped - 60 lines]
.
--
Message posted via AccessMonster.com
.
Gina Whipp said:Okay, then let's forget that and use this...
Create a text box and copy/paste the below...
=IIf([CurrentRecord]>(Count(*)),'No Record',('Contract ' & [CurrentRecord] &
' of ' & Count(*))) & " line(s)"
Note, where is says 'No Record', you can have it say anything or nothing.
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" - Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
The code you gave me works fine if the first parent record that appears on
the form has records in the subform. If that first parent record has no
records in the subform, that's when I get the "No Current Records" error as
soon as I open the database and the debugger highlights the ".MoveLast"
statement.
Gina Whipp said:Is me txtRec_Count a numeric field? OR just and unbound text box? Please
remove *.Value* Is this a form or subform and does it have any records?
What message if any do you get?
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" - Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Here is the code I am using:
With Me.RecordsetClone
.MoveLast
Me.txt_Rec_Count.Value = Me.CurrentRecord & " of " & .RecordCount
&
" line(s)"
End With
Also, I commented out the OnLoad lines
.
.
Gina Whipp said:Okay, then let's forget that and use this...
Create a text box and copy/paste the below...
=IIf([CurrentRecord]>(Count(*)),'No Record',('Contract ' & [CurrentRecord]
&
' of ' & Count(*))) & " line(s)"
Note, where is says 'No Record', you can have it say anything or nothing.
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" - Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
The code you gave me works fine if the first parent record that appears on
the form has records in the subform. If that first parent record has no
records in the subform, that's when I get the "No Current Records" error
as
soon as I open the database and the debugger highlights the ".MoveLast"
statement.
Gina Whipp said:Is me txtRec_Count a numeric field? OR just and unbound text box?
Please
remove *.Value* Is this a form or subform and does it have any records?
What message if any do you get?
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Here is the code I am using:
With Me.RecordsetClone
.MoveLast
Me.txt_Rec_Count.Value = Me.CurrentRecord & " of " &
.RecordCount
&
" line(s)"
End With
Also, I commented out the OnLoad lines
.
.