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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I increment an unbound label? 2

Status
Not open for further replies.

AccessGuruCarl

Programmer
Jul 3, 2004
471
US

Hello all,

I have report that displays the top 6 records, generated from a query.

I added an unbound label to the report called: lblPlace

I want the label to display: 1st, 2nd, 3rd...6th

Here is what a have so far, but it's printing 6th Place for every label... How do I get this to work on a report.

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim x As Integer
For x = 1 To 6
  Select Case x
    Case 1
      Me.lblPlace.Caption = "1st Place"
    Case 2
      Me.lblPlace.Caption = "2nd Place"
    Case 3
      Me.lblPlace.Caption = "3rd Place"
    Case 4
      Me.lblPlace.Caption = "4th Place"
    Case 5
      Me.lblPlace.Caption = "5th Place"
    Case 6
      Me.lblPlace.Caption = "6th Place"
  End Select
Next x

End Sub

Thanks...

AccessGuruCarl
Programmers helping programmers
you can't find a better site.
 
The first thing I would say is to declare your varible at the report level. Each time a line prints on the report it is resetting your variable.

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
Don't use code. Try

Add a text box to your report detail section:
Name: txtPlace
Control Source: =1
Running Sum: Over Group
Visible: No

Add another text box with
Control Source: Choose([txtPlace], "1st", "2nd", "3rd", "4th", "5th", "6th") & " Place"

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Hello dhookom,

Thanks... Works Great!

Here's a star....

AccessGuruCarl
Programmers helping programmers
you can't find a better site.
 
Good stuff. I like the Choose function. Never used that before. A star from me too.

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top