You can download a file which includes the necessary modules for opening a
colour selection dialogue from:
http://www.mvps.org/access/api/api0060.htm
Its Access 97 but will convert to later versions without any problem.
Modify the modColorPicker module so that you can simply return the value of a
selected colour by adding the following function:
Public Function DialogColor() As Long
Dim x As Long, CS As COLORSTRUC, CustColor(16) As Long
CS.lStructSize = Len(CS)
CS.hwnd = hWndAccessApp
CS.Flags = CC_SOLIDCOLOR
CS.lpCustColors = String$(16 * 4, 0)
x = ChooseColor(CS)
If x = 0 Then
' ERROR - use Default White
DialogColor = RGB(255, 255, 255) ' White
Exit Function
Else
' Normal processing
DialogColor = CS.rgbResult
End If
End Function
You can then open the report transparently in design view and modify the
ForeColor properties of the relevant controls, e.g.
Sub PickReportColor()
On Error Goto Err_Handler
Dim rpt As Report
Dim lngColor As Long
lngColor = DialogColor()
Application.Echo False
DoCmd.OpenReport "YourReport", acViewDesign
Set rpt = Reports("YourReport")
rpt!ContactName.ForeColor = lngColor
rpt!AddressLine1.ForeColor = lngColor
rpt! AddressLine2.ForeColor = lngColor
rpt! AddressLine3.ForeColor = lngColor
DoCmd.Close acReport, "YourReport", acSaveYes
Exit_Here:
Application.Echo True
Exit Sub
Err_Handler:
DoCmd.Close acReport, "YourReport", acSaveNo
MsgBox Err.Description
Resume Exit_Here
End Sub
Ken Sheridan
Stafford, England