Dropbox changed value does not appear in its textbox (1 Viewer)

Guidon Mendoza

New member
Local time
Today, 22:17
Joined
May 3, 2021
Messages
19
Hi, everyone!

I hope that someone of good heart can help me solve this.

I developed a platform for a HR company. On it, I give the user the option to add skills to a candidate. And to do that, I have a ComboBox control. Since I need to take actions depending on the keyboard (Return, Esc, Tab and the sort), I capture the keyboard. The case is that when BackSpace is used (event Form_Keydown), the value in the TextBox of the ComboBox is correct, but it does not show.

1648561606850.png

In this case the TextBox should say "Linu" which is the value in it (I traced it).

Code:
   inputKey = GetKey(KeyCode, Shift)
   Set Ctl = Screen.ActiveControl
   Buffer = Ctl
   Debug.Print "Antes " & Buffer
   If Ctl.Name = "SkFlt" Or Ctl.Name = "SpFlt" Then
      Select Case inputKey
         Case "UpperTxt", "LowerTxt", "Txt"
            Buffer = Buffer & Chr(KeyCode)
            KeyCode = 0
         Case "Back"
            If Buffer <> "" Then
               Buffer = Left(Buffer, Len(Buffer) - 1)
            End If
         Case Else
      End Select
      Debug.Print "After value " & Buffer
      Ctl.Value = Buffer

In the code, InputKey is a String that classifies the strocked key. In Buffer I save the value that should be displayed in the TextBox of the ComboBox. I used it to see that the value of Ctl (the ComboBox) is what should be, and it is.

Does anyone have a clue as to what is happening? (And hopefully a hint to the solution).

Thanks in advance!

G
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:17
Joined
Oct 29, 2018
Messages
19,186
Hi. Just a guess but try using ctl.Text instead of ctl.Value = Buffer
 

Guidon Mendoza

New member
Local time
Today, 22:17
Joined
May 3, 2021
Messages
19
It did not work, but thanks for that anyways!
 

Guidon Mendoza

New member
Local time
Today, 22:17
Joined
May 3, 2021
Messages
19
This behavior is not related to any DB, but to the Key_Down event.

After executing GetKey(), InputKey has the type of key strocked (if it's a command, text, special char, function key, etc.), and in KeyCode is the usable (ASCII) code of the key.

Another detail is that when I press again BackSpace it shows for an instant the correct text highlighted, and then it disappears.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 15:17
Joined
Feb 19, 2002
Messages
36,913
Based on what you said you want to do, I can't figure out why you are intercepting keystrokes instead of using the control events.
 

Users who are viewing this thread

Top Bottom