Link to home
Start Free TrialLog in
Avatar of Marta Fuentes
Marta Fuentes

asked on

Printing forms with colors

I'm trying to print a form with a subform in it. Both have diferent backcolors for its records depending on their value. I control it with VBA in detail_paint using backcolor property.
It works till I send it to print. Preview sight is always in black and white.
I have verified the printer properties and it's set to color.
Any help?
Thanks so much
Avatar of PatHartman
PatHartman
Flag of United States of America image

Perhaps the default printer doesn't support color and so Access is helping you or perhaps Access always does this when you attempt to print a  form with a colored background to minimize the use of ink.

In any event, forms are not optimized for printing.  It is better to create a report.
Just start simple...take a screenshot and take a note of the printer properties ...and print it...as it is...does it print OK?
If YES go to your Access...open your form...hit Ctrl+P...now examine ...check your printer...check its properties....do they match when you printed the screenshot...if everything is matched and you still get B/W then either you have issue with your printer (driver ?) or something you tampered in your form...just create a simple test form with colors and retry.
If NO ...i guess something to do with your printer properties.
As Pat said forms are not meant to print so it would be better to create a report
Background colours are usually ignored when printing

Try adding a rectangle with fill colour and place it behind the controls (from the Arrange button: Move to back).
Avatar of Marta Fuentes
Marta Fuentes

ASKER

Well, my form has got a subform in it. I'm able to print in color the records of the form, according to their value in a table. But no colors when printing in the subform records, although when the form is open I can see them in colors.
My code is in the Detail_paint section both for the form and the subform.
Any idea?
Not really. But why not create a report? Contrary to forms, these are intended to be printed.
I tried with a report and also had the same problem.
Then you have some other kind of issue....had you print a screenshot as i advised..?
Can you print your form/report to  PDF (a nice free PDF printer is here) and then print the PDF to your printer to check if you get the colors ?
ASKER CERTIFIED SOLUTION
Avatar of Marta Fuentes
Marta Fuentes

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That makes sense. So will a report serve your purpose?
Well, I am not an expert using reports, I have to filter my data, now. The question was that my customer had anything in forms and he only wanted me to add colors depending on the values of some fields.
I have to change the whole application, now.
But there is still something I don't understand:
I get colors printed in forms, my problem is in subforms...
I can't recall for the last dozen of years or so, that I have printed a form. It's kind of a no-no for most developers.

Perhaps you could provide a small sample to demonstrate the issue?
You can still use the form to filter the data.  Add a button to open the report.  In the button code, you would pick up the filter settings and use those as the WHERE argument of the OpenReport method.

The code you use in the form and subform should also work in the report and subreport.  just put the code in the Format event of the main report or subreport as needed or make it conditional formatting.

You can try saving the form as a report and that might save you some set up but you will probably have to do the subreport separately.  I don't know how smart the save as function is.

Printing forms works OK as long as you don't have background issues but it is subforms that WILL NOT work correctly because they can't paginate.  You will see only what will fit on the first page.

Just get into the habit of making reports and that eliminates all the printing problems.
Hello

Using Reports and SupbReports, it works, I can print in colors. Also, if I only have to print Forms, colors are printing ok.
So, thanks for all your support
Didn't I tell you to switch to a report with a subreport in the FIRST response?  Do you really think you answered your own question or did you select your own answer by mistake?
Hello Moderato

First of all, thanks for your fast answers. All of you have been very nice and useful.
But, the answers that said "Forms are not goods for printing, use a report" were not good enough, as the keys to get the report printing in the same way as I was seeing it in my screen were finding the events involved and shot in each moment: opening the report and print preview. Also, in one of them, don't know why only in one of my reports, I had to code a change in the configuration of the printer.
Anyway, thanks again for being there and for your quick help, probably trying to explain myself and tell you why your answers didn't work made me find the solution.

Sincerely

Marta
Marta,
<<Both have diferent backcolors for its records depending on their value. I control it with VBA in detail_paint using backcolor property.>>

It sounds like you have resolved this, but just wondering if you have tried Conditional Formatting?

Using conditional formatting to set the background color of a control (you can even use a textbox spanning the entire width of your record) might simplify things for you, by eliminating any code you are using to set background colors based on field values.
I have no experience with conditional formats, I will test and tell you, but in fact, the problem is that what I saw in the screen (form open with colors) is not what I got in print preview.
The onlyway I found was converting to reports, as they have the event of detail-format
Make sure you are trying it *separately* from your code, which may conflict with conditional formatting.  In general, it is much easier than using vba to get colored backgrounds... and the colors show up in print previews of reports/subreports and forms/subforms.  
That said, using reports for your printouts is by far the best method, as others have mentioned.
When printing colors the best is using events detail_paint and detail_print. This is the reason why forms are not suitable.
Thanks to all of you for your ideas