Hi,
I have two text boxes in a login form, and both have the same issue. I'm using the [Change()] event to check the number of characters typed manually to change the Text Box's background color.
The problem is that the (.Value) property doesn't reflect changes made while the focus is on the respective Text Box. Therefore, the color change only occurs when the focus moves to another control.
Similarly, whenever the text box is updated, the [AllControls_Change()] procedure is called to check if the fill is Ok and activate the [Cmd_Ok] button.
I found that if I change the property from (.Value to .Text) in the Change() event, it works, but it fails in the [AllControls_Change()] procedure, because of the Focus control.
The code below doesn't work in the [usertxt] control:
P.s. I am attaching a file with the Form, for test purpouses.
Many thank's in advance.
I have two text boxes in a login form, and both have the same issue. I'm using the [Change()] event to check the number of characters typed manually to change the Text Box's background color.
The problem is that the (.Value) property doesn't reflect changes made while the focus is on the respective Text Box. Therefore, the color change only occurs when the focus moves to another control.
Similarly, whenever the text box is updated, the [AllControls_Change()] procedure is called to check if the fill is Ok and activate the [Cmd_Ok] button.
I found that if I change the property from (.Value to .Text) in the Change() event, it works, but it fails in the [AllControls_Change()] procedure, because of the Focus control.
The code below doesn't work in the [usertxt] control:
Code:
Private Sub usertxt_Change()
'Occurs evry key Pressed
'Stop
' MsgBox Len(Trim$(Me.usertxt.Value))
If Len(Trim$(Me.usertxt.Value) & vbNullString) > 0 Then
Me.usertxt.BackColor = RGB(255, 255, 204) '#FFFFFF '&H80000005
Else
Me.usertxt.BackColor = RGB(255, 255, 255) '&HC0FFFF
End If
AllControls_Change
End Sub
Public Sub AllControls_Change()
'Function to activate Ok Button.
Dim flg As Boolean
flg = (Len(Trim$(Me.usertxt.value)) = 7 And Len(Trim$(Nz(Me.passwtxt.value, ""))) > 0)
''Tenho de usar, por precaução, a propriedade text. (altera no evento Change), pois o Value só é alterado no
''AfterUpdate. Com isto o user pode deletar o dado e sem retirar o cursor podia ainda clicar no Botão Activo...
'Enabled_Event:
Me.Cmd_Ok.Enabled = flg
End Sub
P.s. I am attaching a file with the Form, for test purpouses.
Many thank's in advance.