PDA

View Full Version : Solved: TextBox BackColor when Enable



ioncila
12-31-2009, 09:21 AM
Hi
May be I dont get it because I'm already thinking of "night reveillon" :)
so I'm asking a little help, if You please

The code below works on a userform (frmAlterar) and it setups enable/disable textboxes of another userform (frmRegisto) by choosing one of the buttons.

This works very fine.

The problem is that the enabled textboxes appear with Backcolor in BLACK and I would want to be the default color of textbox when enable (White).

How do I fix that?

Private Sub HabilitaControles2() 'CORRIGIR DADOS
frmRegisto.txtNOME.Locked = False
frmRegisto.txtTIPO.Locked = False
frmRegisto.txtMATERIAL.Locked = False
frmRegisto.txtMARCA.Locked = False
frmRegisto.txtMODELO.Locked = False
frmRegisto.txtDN1.Locked = False
frmRegisto.txtDN2.Locked = False
frmRegisto.txtPN.Locked = False
frmRegisto.txtDATA.Locked = False
frmRegisto.txtLOC.Locked = False
frmRegisto.txtPRECOUNIT.Locked = False
frmRegisto.txtRESPONSAVEL.Locked = False
frmRegisto.txtOBS.Locked = False

frmRegisto.txtNOME.BackColor = corEnabledTextBox
frmRegisto.txtTIPO.BackColor = corEnabledTextBox
frmRegisto.txtMATERIAL.BackColor = corEnabledTextBox
frmRegisto.txtMARCA.BackColor = corEnabledTextBox
frmRegisto.txtMODELO.BackColor = corEnabledTextBox
frmRegisto.txtDN1.BackColor = corEnabledTextBox
frmRegisto.txtDN2.BackColor = corEnabledTextBox
frmRegisto.txtPN.BackColor = corEnabledTextBox
frmRegisto.txtDATA.BackColor = corEnabledTextBox
frmRegisto.txtLOC.BackColor = corEnabledTextBox
frmRegisto.txtPRECOUNIT.BackColor = corEnabledTextBox
frmRegisto.txtRESPONSAVEL.BackColor = corEnabledTextBox
frmRegisto.txtOBS.BackColor = corEnabledTextBox
End Sub

Private Sub HabilitaControles3() 'ENTRADA DE MATERIAIS
frmRegisto.txtENTRADAS.Locked = False
frmRegisto.txtDATA.Locked = False
frmRegisto.txtPRECOUNIT.Locked = False
frmRegisto.txtORIGEM.Locked = False
frmRegisto.txtRESPONSAVEL.Locked = False
frmRegisto.txtOBS.Locked = False

frmRegisto.txtENTRADAS.BackColor = corEnabledTextBox
frmRegisto.txtDATA.BackColor = corEnabledTextBox
frmRegisto.txtPRECOUNIT.BackColor = corEnabledTextBox
frmRegisto.txtORIGEM.BackColor = corEnabledTextBox
frmRegisto.txtRESPONSAVEL.BackColor = corEnabledTextBox
frmRegisto.txtOBS.BackColor = corEnabledTextBox
End Sub

Private Sub HabilitaControles4() 'SAIDA DE MATERIAIS
frmRegisto.txtSAIDAS.Locked = False
frmRegisto.txtDATA.Locked = False
frmRegisto.txtPRECOUNIT.Locked = False
frmRegisto.txtDESTINO.Locked = False
frmRegisto.txtRESPONSAVEL.Locked = False
frmRegisto.txtOBS.Locked = False

frmRegisto.txtSAIDAS.BackColor = corEnabledTextBox
frmRegisto.txtDATA.BackColor = corEnabledTextBox
frmRegisto.txtPRECOUNIT.BackColor = corEnabledTextBox
frmRegisto.txtDESTINO.BackColor = corEnabledTextBox
frmRegisto.txtRESPONSAVEL.BackColor = corEnabledTextBox
frmRegisto.txtOBS.BackColor = corEnabledTextBox
End Sub

Private Sub CommandButton1_Click()
With frmRegisto
Call HabilitaControles3
End With
frmAlterar.Hide
End Sub

Private Sub CommandButton2_Click()
With frmRegisto
Call HabilitaControles4
End With
frmAlterar.Hide
End Sub

Private Sub CommandButton3_Click()
With frmRegisto
Call HabilitaControles2
End With
frmAlterar.Hide
End Sub


Note: corEnabledTextBox appears in the project code as Constant, like the following:
Const corDisabledTextBox As Long = -2147483633
Const corEnabledTextBox As Long = -2147483643

In spite of I have copied this from another code, that dont affect any of similar subs of the entire project.
The backcolor in BLACK only appears in this three subs (HabilitaControles2, HabilitaControles3 and HabilitaControles4)

Thanks in advance and HAPPY NEW YEAR
Ioncila

xld
12-31-2009, 11:07 AM
Public Const corDisabledTextBox As Long = -2147483633
Public Const corEnabledTextBox As Long = -2147483643

ioncila
12-31-2009, 11:55 AM
Public Const corDisabledTextBox As Long = -2147483633
Public Const corEnabledTextBox As Long = -2147483643


Thanks for reply
There is a problem however wiyh your suggestion:

It returns
Compile error:
Constants, fixed-lenghtstrings, arrays, ... not allowed as Public members of object modules.

I only added 'Public' before Const, as you mentioned.
Do I have to do Something more?

Project code begins like that:
Option Explicit

Const colCOD As Integer = 1
Const colNOME As Integer = 2
Const colTIPO As Integer = 3
Const colMATERIAL As Integer = 4
Const colMARCA As Integer = 5
Const colMODELO As Integer = 6
Const colDN1 As Integer = 7
Const colDN2 As Integer = 8
Const colPN As Integer = 9
Const colENTRADAS As Integer = 10
Const colSAIDAS As Integer = 11
Const colEXISTENCIAS As Integer = 12
Const colDATA As Integer = 13
Const colLOC As Integer = 14
Const colPRECOUNIT As Integer = 15
Const colVALORTOTAL As Integer = 16
Const colORIGEM As Integer = 17
Const colDESTINO As Integer = 18
Const colRESPONSAVEL As Integer = 19
Const colOBS As Integer = 20

Const indiceMinimo As Byte = 2
Const corDisabledTextBox As Long = -2147483633
Const corEnabledTextBox As Long = -2147483643

Private wsCadastro As Worksheet
Private indiceRegistro As Long

Happy New Year
Ioncila

xld
12-31-2009, 12:27 PM
Which module are those constants declared in?

ioncila
12-31-2009, 12:41 PM
There are in "frmRegisto" code

GTO
12-31-2009, 09:37 PM
There are in "frmRegisto" code

Hi there :-)

Just cuz Bob's most likely counting sheep...

Move them to the top of a Standard Module.

Mark

ioncila
01-02-2010, 07:17 AM
Hi there :-)

Just cuz Bob's most likely counting sheep...

Move them to the top of a Standard Module.

Mark

Thank you very much.

Its done and solved.

Happy New Year
Ioncila