PDA

View Full Version : Solved: make all backcolor white before print



Emoncada
01-07-2008, 06:07 PM
Is there a way to make all Back color of userform white. I have this code

'--------------------Shipped By Name Enter----------------------------
Private Sub TxtShippedBy_Enter()
Me.TxtShippedBy.BackColor = RGB(0, 200, 200)
End Sub
'--------------------Shipped By Name Exit----------------------------
Private Sub TxtShippedBy_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Me.TxtShippedBy.BackColor = RGB(255, 255, 255)
End Sub

This works great it makes the backcolor of the active txtbox or cmbbox lite blue. But When I print what ever box was selected stays with the lite blue color and prints like that. Any Ideas?

malik641
01-07-2008, 06:46 PM
How are you printing the userform? Are you using "Me.PrintForm"?

Emoncada
01-07-2008, 07:21 PM
Yeah basically I just have another form that is my printform which has Userform1.printform on it.

malik641
01-07-2008, 07:37 PM
Ok. Then you could try to switch the color anyway you want it right before you say "Userform1.PrintForm", and then just change it back to what it was after that line of code.

Or is there more to it that I just don't see?

Emoncada
01-07-2008, 07:44 PM
Yeah. Is there a way to say Active Tab Change Backcolor? Because there are over 30 txtboxes and over 18 Cmbboxes and my color code appears on entering one of them and then changes to white when exiting, but if they click the save/Print button and one of the txtboxes are highlighted in the color it prints out.

malik641
01-07-2008, 08:22 PM
I don't see why that would happen, though. Once you click the button to print/save, the Exit event of the active textbox would occur before the code in the button would activate...well, that's what I understand should happen.


From the Help:
Exit occurs immediately before a control loses the focus to another control on the same form.

Maybe you could try UserForm1.Repaint before you try to print...???

If that doesn't work, could you possibly show us some more code?

Emoncada
01-07-2008, 08:40 PM
ok what i did was I setfocus a value before print and made the backcolor white. Then after print setfocus and changed it back to blue.

malik641
01-10-2008, 11:16 AM
I'm still surprised at how the textbox control still had the focus even after you clicked a button. Unless you didn't click a button, but use a keyboard combo?

Either way, glad you have resolved it :)