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

trouble with dmax function- code in Access Report 1

Status
Not open for further replies.

STRATMAN1

Programmer
Jun 17, 2004
19
US
I have been attempting to shade a control in a report when the highest value in a query field is shown. I received some assistance in the form of code suggestion as follows:
Option Compare Database
Option Explicit
'Global declaration to hold the max value
Dim lngMax As Long

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
'This will be run everytime a record in the detail section
'is rendered on the report. You can use it to change the
'formatting of the detail, a field, text...
If Me.lngRecord = lngMax Then 'Check the record data
'Make the control BackColor grey because I am the
'the max value
Me.Controls("lngRecord").BackColor = 12632256
Else
'Reset the BackColor to the default because I don't
'match
Me.Controls("lngRecord").BackColor = 16777215
End If
End Sub
Private Sub Report_Open(Cancel As Integer)
'Use the DMax() function to find the max value
lngMax = DMax("lngRecord", "tblColumnWrap")
End Sub

I cant seem to get the backcolor to change and I think it is the dmax function. when i set the lngrecord=lngmax, none of the fields shade, but if I set lngrecord >lngmax, they all do. I am not sure why this wont work as suggested, but willing to try again. All good advice appreciated.
 
This suggests to me that lngRecord is not defined as a long integer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top