PDA

View Full Version : [SOLVED:] backcolor = bordercolor not working



Trevor
04-03-2008, 03:18 PM
I am trying to have the bordercolor of my textboxes = the backcolor of the texbox and It isn't working if i use


Actextbox.bordercolor = actextbox.Backcolor ' I get type mismatch (obviously)


I am using and not working

' this is onload click()
For Each Control In Me.Controls
If Control.ControlType =AcTextbox Then
Textbox.BorderColor = TextBox.BackColor
Exit For
End If
Next
End Sub

Thanks for Helping

orange
04-03-2008, 06:15 PM
I am trying to have the bordercolor of my textboxes = the backcolor of the texbox and It isn't working if i use


Actextbox.bordercolor = actextbox.Backcolor ' I get type mismatch (obviously)

I am using and not working

' this is onload click()
For Each Control In Me.Controls
If Control.ControlType =AcTextbox Then
Textbox.BorderColor = TextBox.BackColor
Exit For
End If
Next
End Sub
Thanks for Helping
Trevor,

I think you need to replace these lines

Textbox.BorderColor = TextBox.BackColor
Exit For
with this one ( and you don't want to Exit For unless you only want to change the first textbox)


Control.BorderColor = Control.BackColor

Trevor
04-04-2008, 09:38 AM
I thmught I still had to proporly termiate my for , but anyway I got it working, I had to add


Control.BorderStyle = Trasperent
Control.SpecialEffect = Flat

I don't know why when you use for each to set a proporty setting access likes to change other setting so you have to add lines in for the setting access decided to change on it's own

orange
04-04-2008, 12:25 PM
I thmught I still had to proporly termiate my for , but anyway I got it working, I had to add


Control.BorderStyle = Trasperent
Control.SpecialEffect = Flat
I don't know why when you use for each to set a proporty setting access likes to change other setting so you have to add lines in for the setting access decided to change on it's own

Trevor,

For Each
...
...
Next

The Next terminates the For loop. The Exit For is an abnormal exit from the Loop.


The BorderStyle and SpecialEffect are separate properties, not part of your original question.

Trevor
04-04-2008, 04:25 PM
yes your right on the 2 proporties not part of my OP but when I used my OP and later with your suggestion aceess automaticly set special effect to sunkin, and the bordercolor didn't seem to change like it should had so i just got rid of the border
I usualy you exit for and next together , so that how I can easily forget which is which :)

Trevor
04-04-2008, 06:33 PM
I am trying to exclude textboxes with a tag that isn't blank and it isn't working


Private Sub Form_Load()
On Error GoTo ErrorHandl:
For Each Control In Me.Controls
If Control.ControlType = acTextBox And Control.Control.Tag = "" Then ' or Control.Tag = "" then isn't working either
Control.BorderStyle = Transparent
Control.SpecialEffect = Flat
Control.Locked = True
End If
Next
UnboundTextBox.SetFocus
ErrorHandl:
MsgBox Err.Number
End Sub

Carl A
04-05-2008, 06:47 AM
Dim indx As Integer
With Me.Controls
For indx = 0 To .Count - 1
If Me.Controls(indx).Tag = "1" Then 'Set tag to those controls you need to change
If (TypeOf Me.Controls(indx) Is Label) Then 'is it a label?
Me.Controls(indx).BorderStyle = 0 'Transparent
Me.Controls(indx).BackColor = RGB(255, 0, 0) 'Red
Me.Controls(indx).Locked = True
End If
End If
Next indx
End With
End Sub


To Check for TextBox and clear contents:


Dim indx As Integer
With Me.Controls
For indx = 0 To .Count - 1
If Me.Controls(indx).Tag = "1" Then
If (TypeOf Me.Controls(indx) Is TextBox) Then
Me.Controls(indx).SetFocus 'will error without setting focus
Me.Controls(indx).Text = ""
End If
End If
Next indx
End With

Trevor
04-05-2008, 10:05 AM
Thanks carlA but that looks like the long way of doing what I have already done, I mananged a workaround by putting a rectagle around the texbox that I wanted a border on
what I was trying to do is using my for control statement to apply to all but exclude a textbox by tag not being blank

Carl A
04-05-2008, 01:20 PM
I am trying to exclude textboxes with a tag that isn't blank and it isn't working

Code was intended to show you how to iterate through your controls. As you were having problems. :115:

Trevor
04-05-2008, 08:04 PM
oohh. My brain must be on vacation.. I thaught you were trying to show me another way of doing the same thing as trying to do in my OP.
I did come up with a workarround that saves alll that code, i just put a rectagle around the text box so to the enduser it looks like a border.. Thanks :-)