How to set text box background to clear when in focus? (1 Viewer)

tormodnt

Registered User.
Local time
Today, 16:13
Joined
Nov 7, 2008
Messages
17
I have a large textbox (memo field) that I would like not to get a background color when i focus..
I would like it to be "transparent" if you understand.
Like when it's not in focus..
Reason for transparent is that I have a good background image..
(it's a diary and the background image is "old paper"), and It just look strange when it's that big!

I have looked at (sorry using a Norwegian access so don't know what is called in english) the control where you can change how it looks like when selected, but no clear backgrounds there..

Could this be done?

If this is not a possibility, how to show scrollbar when not focus on text (memo) fields
This way at least the customer could read all the text with the clear background, when he only going to read it and not edit..

Best regards
Tormod
Norway
 
In the Got Focus event put;
Code:
Me.ControlName.BackStyle = Transparent

of course on the Lost Focus event you will need;
Code:
Me.ControlName.BackStyle = Normal
 
I'm pretty sure that Memo fields only get a scroll bar when they have focus.
 
Seams like the "Me.ControlName.BackStyle = Transparent" doesn't work..
Still color.. is there more I should do then put in the code?

(No error message, so I'm guessing the code itself passes)
 
It works, it's probably not doing what you expect. You could try;
Code:
Me.Text2.BackColor = 16777215

16777215=White, 0=black

Once again you will need code in the Lost Focus event to return the control to it's default.
 
As John said, making the textbox BackStyle Transparent may not necessarily give you the results you expected! When the textbox BackStyle is transparent, it takes on the color of the form's section beneath it.
 
Well.. for me it doesn't.. :confused:

Textbox:
My text box is named: Dagbokinnlegg
Background style: Transparent
Border style: Transparent

My form:
My background color on the form: #1F497D

And my code is:
Private Sub Dagbokinnlegg_GotFocus()
Me.Dagbokinnlegg.BackStyle = Transparent
End Sub

Private Sub Dagbokinnlegg_LostFocus()
Me.Dagbokinnlegg.BackStyle = Normal
End Sub

So not getting this to work I made a new text box and named it "Dato" and tried to set the color to black:

Private Sub Dato_GotFocus()
Me.Dato.BackStyle = 0
End Sub

Private Sub Dagbokinnlegg_LostFocus()
Me.Dagbokinnlegg.BackStyle = Normal
End Sub

Same result with both, they get solid white when I click on them..
 
What version /service pack of Access are you running and what version of Windows? Acccess 2003 running under Windows XP has had some problems with graphical display. I've seen specific reports of this kind of problem with combobxes, but none of textboxes. This may simply be because setting the backstyle of a textbox to transparent is something few do. If you're running Acccess 2003 under Windows XP post back and I'll try to track down a workaround.
 
I run:
Microsoft Windows Vista Business
6.0.6001 Service Pack 1 Build 6001

Microsoft Access 2007 1.2.6304.5000
SP1 MSO 12.0.6320.50000
Part of Microsoft Office Enterprise 2007

No cracked versions, all legal straight from the box..
 
That's right, when the field has focus you should see a grey background (Normal) but when the field doesn't have focus you should see the stone pattern of the form (transparent).
 
aha! there is our miss communication! :)
It's not easy to explain when English is not my first languish! ;)

What I want is it to be transparent even if it got focus!

No wonder we didn't understand each other answers *lol*
 
Thank you, that's just to bad!

well, If this is not a possibility, is there a possibility to set the text box property to locked and not active and still activate the scrollbar?

-if this would be possible the user could just lock it down when finish editing..
This way at least the customer could read all the text with the clear background, when he only going to read it and not edit..
 
My apologies for creating confusion before.

As Bob mentioned the act of getting focus automatically sets the BackStyle to Normal irrespective of any code that may be behind the text box.

As to your proposition of locking the text box, but still having the scroll bar. Yes that is possible.

You would just set;
Code:
Me.ControlName.Locked = True
This would prevent further data entry to the Field. However for the Scroll bar to be activated the Text Box must gain focus, so you should not set Enabled = False
 
Thank you, that's just to bad!

well, If this is not a possibility, is there a possibility to set the text box property to locked and not active and still activate the scrollbar?
Nope, if you go to scroll, it activates the box and you lose the transparent background.
 
Ok!

Then I just have to drop the idea, and go for a solid colored background instead of the image.

Thank you all!

Best regards
Tormod Torgersen
Norway
 
Unless I have completely misunderstood what you want, the following code will make a specific Text Box appear fully Transparent even when Focus is applied to the Control. Without Focus there is no Vertical Scroll Bar until focus is applied. The Control is also automatically Locked so that Editing can not be done. The Control's Border is also Transparent.

The code pulls the currently set Background color for the Details section of the Form where the majority of Controls usually reside and then applies it to the Back Ground color of the Text Box. Regardless of what the Back Ground Color of the Form's Detail section might be, the Text Box Back Ground Color will also carry that Back Ground Color.

You an place the Code into the Form's OnOpen event:

Code:
Private Sub Form_Open(Cancel As Integer)
   Me.[COLOR="Red"][I]YourTextBoxName[/I][/COLOR].BackColor = Me.Section(acDetail).BackColor
   Me.[I][COLOR="Red"]YourTextBoxName[/COLOR][/I].ScrollBars = 2   [COLOR="DarkGreen"]'0 = None | 2 = Vertical Only | There is no Horizontal For Text Boxes.[/COLOR]
   Me.[I][COLOR="Red"]YourTextBoxName[/COLOR][/I].BorderStyle = 0  [COLOR="DarkGreen"]'0 = Transparent | 1 = Solid[/COLOR]
   Me.[I][COLOR="Red"]YourTextBoxName[/COLOR][/I].BackStyle = 0    [COLOR="DarkGreen"]'0 = Transparent | 1 = Normal[/COLOR]
   Me.[I][COLOR="Red"]YourTextBoxName[/COLOR][/I].Locked = True    [COLOR="DarkGreen"]'True = Locked | False = UnLocked[/COLOR]
End Sub

Make sure the items in italic red contain the proper Text Box name.

The trick is to apply the Back Ground Color of the Text Box before you set the Back Style property. Whenever the Back Ground color of a Control is changed, the Controls Back Style property automatically reverts to Normal. Setting the Back Ground Color first then the Back Style property takes care of this.

.
 
Last edited:
From what I can see from having a play with your code; is that your code sets the back colour of the Text box to match the underlying colour of the form. It does however, have no effect on the BackStyle. As a textbox reverts to BackStyle = Normal as soon as it get focus.
 

Users who are viewing this thread

Back
Top Bottom