Access 2003

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am creating a form in Access 2003 and would like to add an option to change
the font color to the report that is selected on the form. The report is for
labels and I would like to add a color pallette to the form as an option.
How would i do this?
 
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
 
Anne said:
I am creating a form in Access 2003 and would like to add an option to
change
the font color to the report that is selected on the form. The report is
for
labels and I would like to add a color pallette to the form as an option.
How would i do this?

Ken was gracious to answer your question, but you'd have been far better off
to have begun a new thread, rather than tack it on as a response to a
question with different subject matter. Many qualified participants do not
have time to open every post, so are guided by the subject as to which they
believe they can help. For other good suggestions on effective use of
newsgroups, see the FAQ at http://www.mvps.org/access/netiquette.htm.

Larry Linson
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top