changing the backcolor of a Box in a report

J

jean.ulrich

Hi

I have a form and on this form I have a command button that opens a
report.

In the report there is a box "Box112" with grey color background

I would like to created 5 customised buttons to open the same report

Let say I use a box and on the on click I put a command such as

Dim stDocName As String
stDocName = "ReportA"
DoCmd.OpenReport stDocName, acPreview

Let say the 5 buttons on the form have 5 different colors red, blue,
green, yellow and orange

If I click on the red button, ReportA opens with Box112 having a red
background
If I click on te blue button, ReportA opens with Box112 having a blue
background
and so on

I have try to put some code after te "DoCmd.OpenReport stDocName,
acPreview" line like
Box112.backcolor = 155 (or other number) but it did not work

thanks
 
T

tina

put the color number you want in the OpenArgs argument of the OpenReport
code, as

DoCmd.OpenReport stDocName, acViewPreview, , , , "155"

add code to the *report* Open event, as

Private Sub Report_Open(Cancel As Integer)

Me!Box112.BackColor = CLng(Me.OpenArgs)

End Sub

rather than using 5 command buttons, with corresponding code on each, you
might want to consider using a listbox, combobox, or option group to list
the colors the user may choose from, with a single command button to open
the report. (a combo box might be especially useful - easy to expand the
colors offered, without increasing the form "real estate" used.) set the
OpenArgs argument to the name of the "colors choice" control, rather than to
a hard-coded numeric value.

hth
 

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

Top