Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Duplicate "Record x of y" 1

Status
Not open for further replies.
Jun 2, 2004
66
US
I am looking to duplicate the "Record x of y" label that appears in the standard Navigation toolbar?

I am well aware that there are other threads relating to this issue, but I have not been able to get any of them to work. The code that I found (below) seemed to be the most logical, but I am still getting an error. Any ideas why?



A)Given that you have a label on the form called lblNavigate, put this code in the form's OnCurrent Event.


'************** Code Start **************
Private Sub Form_Current()
If Me.NewRecord Then
Me!lblNavigate.Caption = "New Record"
Else
With Me.RecordsetClone
.Bookmark = Me.Bookmark
Me!lblNavigate.Caption = "Record " & _
.CurrentRecord _
& " of " & .RecordCount
End With
End If
End Sub

************** Code End **************
 
I am still getting an error[/b]
Any chance you could post the whole error message and which line is highlighted ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Run Time Error 438.

Object doesn't support this property or method



Here is what is highlighted.


Me!lblNavigate.Caption = "Record " & _
.CurrentRecord _
& " of " & .RecordCount

Thanks
 
Have you tried to replace this:
.CurrentRecord _
By this:
.AbsolutePosition _

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thank you very much. Now for some reason it gives me record # 0 for the first record. Is there any way to have it start at record 1.

Thanks.
 
Try this:
Me!lblNavigate.Caption = "Record " & _
(.AbsolutePosition + 1) _
& " of " & .RecordCount

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
That does it. Unfortunately, I have a bit of a conflict with my search form now. For some reason, the search is not operable since I added this code. Without going into detail about the search form, is there any other reference I could use besides Absolute.Position?

Thanks
 
You might try the following:

1. In the OnCurrent of the form place this code:

Private Sub Form_Current()
If Me.NewRecord Then
Me.lRecordXofY.Caption = "New Record (" & DCount("*", "TableName") & " existing records)"
Else
Me!lRecordXofY.Caption = "Record " & [CurrentRecord] & " of " & DCount("*", "TableName")
End If
End Sub

2. Then on the form, make an unbound label (make sure it is long enough) and name it lRecordXofY

HTH

An investment in knowledge always pays the best dividends.
by Benjamin Franklin
Autonumber Description - FAQ702-5106
 
Thanks, but I'm having the same problem. The Search Form that I use automatically returns the results by going back to my Master Form. I then navigate through my records the same way I would do without filtering the results. For some reason, with the codes that you have both shown me, this Search Form has become inoperable.

Is there a way to attach this code somewhere else? Could I add a field to my Master Table called ReturnXofY and use the code? How about a query?
 
Not sure of the code you may be using and not sure why there is a problem. One thing you might try is creating a new search form. Maybe the one you are using has become corrupted. You can also try just creating a button from the wizard to search. If that works, keep going from there.

HTH

An investment in knowledge always pays the best dividends.
by Benjamin Franklin
Autonumber Description - FAQ702-5106
 
I have determined that the problem is that both the Search Form and the code to "display x of y" use the RecordCount function.
The below code is used in my Search Form.....
If Forms![Master Form].RecordsetClone.RecordCount = 0 Then
MsgBox "No records match the criteria you entered.", 48, "No Records Found"
Else
WhereSearch = 1
DoCmd.Close
End If
Exit Sub
This code is run after I select my criteria and click ok on the search form. It then takes me back to my Master Form and shows me the results. If I am using the "display x of y" code, the Master Form closes and the Search Form stays open while all of the buttons become disfunctional.


When I remove this from the Search Form code, the display x of y code works properly. Perhaps there is another way to structure the code without the use of RecordCount?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top