VBA Excel UserForm: Cursor does not show in active texbox

77 views Asked by At

In a UserForm in Excel I have a TextBox called ScanInput_Fx which is used repetitively to enter data. Each time the data is processed ScanInput_Fx is emptied and the focus returns to it. Or better: it stays on ScanInput_Fx since I use the Cancel = True option of the _BeforeUpdate event. But, for whatever reason sometimes the cursor does not display. I have tested to make sure that the focus is actually on ScanInput_Fx (by calling the name of the ActiveControl in a msgbox and by pushing text from the VBA code into the ActiveControl) and it really is.

The only thing the user can do is to manually click ScanInput_Fx again. But, that is not really an option as the user is entering the data with a scanner and he is not near the computer.

I have read lots of threads about this, but have not found a working solution. I have tried moving focus to another Control and the back to ScanInput_Fx, but that does not work neither. Strange thing is also that when I ommit the Cancel = True option (of the _BeforeUpdate event) the focus does not jump to the next Tabposition on the form, even not when I hardcode it in VBA. Not sure these two things are related, but maybe it does ring a bell to someone.

Some additional context (as I cannot display all the code here). This is what the code of the _BeforeUpdate Event does:

  • it checks whether the value entered in ScanInput_Fx is valid against a look up in an array
  • it adds a counter of 1 to another Control on the form that corresponds with the data entered in ScanInput_Fx
  • it puts the value of ScanInput_Fx in cell on the underlying excel sheet and saves that sheet as a PDF

So, to my opinion nothing very spectacular. The only thing that may be special is that most of the controls on the form are dynamically created by a function. But, ScanInput_Fx that is showing this erratic behaviour is fixed on the screen (so not dynamically created)

Would there be anyone with some advice on what I can do or where I can start to look for an answer?

Thanks in advance for your help.

Renaat

0

There are 0 answers