Mar 29 2024 08:28 PM
Using the Enter and Exit functions for text boxes, I can't get them to change color consistently. Using tabs the color changes ok, but clicking around on different text boxes, the color does not always change. I have looked at the code very closely and don't know what is going on. Could someone help me resolve?
Private Sub txtPROGRAMManager_Enter()
txtPROGRAMManager.BackColor = RGB(206, 234, 235)
End Sub
Private Sub txtPROGRAMManager_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtPROGRAMManager.BackColor = vbWhite
End Sub
Mar 30 2024 02:10 AM
Could you attach a small sample workbook demonstrating the problem (without sensitive data), or if that is not possible, make it available through OneDrive, Google Drive, Dropbox or similar?
Mar 30 2024 02:05 PM
@Hans Vogelaar here is a copy of the program,, whne you open it, click on the "ECO" button, and it will take you to the form. If you click on the text boxes that I have changing color in the code, they do not resort back to the white color all the time, take a look and click around, see if you can see anything odd. Thanks much.
Mar 30 2024 02:23 PM - edited Mar 30 2024 02:23 PM
Thank you. I've clicked around hundreds of times, but the behavior was consistently correct.
I'm using Excel in Microsoft 365 version 2403 (32-bit) on Windows 11 Home version 23H2 (64-bit).
Mar 30 2024 06:02 PM
Mar 31 2024 02:44 AM
Yes, I did click from frame to frame, and more specifically from txtREQUESTERName to cmbUPDATEType and back, and it worked correctly every time.
But now it gets weird: when I reopened the workbook this morning, I did see the problem for some controls. I then closed and reopened the workbook, and it occurred for a different set of controls.
It seems that the Enter and Exit events do not always fire consistently.
One suggestion: add the line
txtDate_opened.BackColor = vbWhite
to fram_REQ_SPECIFIC_CHANGES_Enter and to fram_ENG_CHANGE_INFO_Exit.
Mar 31 2024 05:49 AM
Mar 31 2024 07:43 AM
I see that too, intermittently. Sometimes, the txtREQUESTERName_Enter event doesn't occur when it should. You can probably mitigate it by adding _MouseDown event procedures, such as you already have for cmbUPDATETYPE:
Private Sub txtREQUESTERName_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
txtREQUESTERName.BackColor = RGB(206, 234, 235)
End Sub
Do the same for all such controls.
Mar 31 2024 09:00 AM
Mar 31 2024 09:07 AM
As far as I can tell, it is a bug in the way userforms raise events for controls in frames. The problem is mentioned in other forums.
Mar 31 2024 01:48 PM
take a look at my changes,, now we have another issue,, I have the Urgency box as a dropdown, not only does it not populate, but nothing happens. the same with the Update Type,,, what do we do now? Thanks.
Mar 31 2024 02:55 PM
This is really buggy - the MouseDown event apparently cancels the Change event.
Using the keyboard to select an item still works.
Is it really worth all this trouble to highlight the active control?
Mar 31 2024 04:21 PM
Apr 02 2024 12:18 PM
Apr 02 2024 12:26 PM