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

report of only labels - not running Detail onFormat event

Status
Not open for further replies.

redwoodly

Programmer
Apr 10, 2002
64
0
0
US
I created a map of a casino floor - in a form using only labels. (The form works great)

Reason: the data displayed in the label doesn't change, the label shows the unique location designation of the machine (ex. AA0101) in the exact position it is located on the casino floor. The values of the recordset are displayed based on the label name by using the label backcolor - so each machine shows up as red or yellow, or green, for example, indicating if the value is a lot (hot/red) or little (cold/green), etc.

All works great.

But I'd like to get this in a report so a user can just print it. (currently i screen print the form)
As it took a long time to create all the labels for all the machines showing the floor configuration, I simply copied and pasted them into a report in the detail section.
I declared my db and recordset variables in the header of the module.
Then set them in OpenReport event
Then put my label coloring code in the Detail OnFormat event - with breakpoints

And when i run the report - it never even processes the Detail OnFormat event - doesn't break at any of the breakpoints.
I added a debug.print and nothing.
Why wouldn't it even go there? is it because i am using only labels?
So it isn't coloring my labels in the report.
Any suggestions on how to fix or make this in a different way?
Thank you for your help.
Option Compare Database
Public DB As DAO.Database
Public rs As DAO.Recordset

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

Dim intAvg As Integer
Dim lngRed As Long
Dim lngOrange As Long
Dim lngYellow As Long
Dim lngGreen As Long
Dim lngBlue As Long
Dim lngGrey As Long
Dim strFrm As String

Debug.Print

If rs.RecordCount > 0 Then

strFrm = "RptAvg"

lngRed = RGB(255, 0, 0) '(237, 28, 36)
lngOrange = RGB(255, 194, 14)
lngYellow = RGB(255, 242, 0)
lngGreen = RGB(167, 218, 78)
lngBlue = RGB(119, 192, 212)
lngGrey = RGB(165, 165, 165)

With rs
.MoveFirst
Do Until rs.EOF
strID = rs!location
intAvg = rs!AvgPDay

strName = "lbl" & strID

If fIsRptCtl(strFrm, strName) = False Then

GoTo MoveOn
End If


Select Case intAvg
Case -100000 To -1
Me(strName).BackColor = lngGrey
Case 0 To 50
Me(strName).BackColor = lngBlue
Case 51 To 100
Me(strName).BackColor = lngGreen
Case 101 To 150
Me(strName).BackColor = lngYellow
Case 151 To 200
Me(strName).BackColor = lngOrange
Case Is > 201
Me(strName).BackColor = lngRed

End Select

MoveOn:
varBookmark = .Bookmark
rs.MoveNext

Loop
End With
End If


End Sub

Private Sub Report_Close()
If IsObject(rs) Then rs.Close
If IsObject(DB) Then DB.Close
Set rs = Nothing
Set DB = Nothing
End Sub

Private Sub Report_Open(Cancel As Integer)
Dim qdf As QueryDef
Set DB = CurrentDb()
Set qdf = DB.QueryDefs("qryRptMapB")
Set rs = qdf.OpenRecordset()

End Sub
 
Need to open in Print Preview view.
 
I would probably place all the machines in a table with the coordinates and size. Then use code in the On Format event of the detail section to position and size a single text box. You can find some similar code in the Calendar Reports.



Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top