Results 1 to 5 of 5

Thread: Textbox Question

  1. #1
    Guest

    Red face

    Is there a way to call a command button when enter is pushed in a textbox without having it beep and still retaining the password char? I tried making it multiline and putting its selstart back to 1 before calling the command button and that worked but it no longer uses the password char when its multiline.

  2. #2
    Hyperactive Member
    Join Date
    Sep 1999
    Posts
    305
    you could set that command button's Default to True. That way, whenever enter is pressed, the command button is activated.

    bob

  3. #3
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    unfortunately it still beeps?? but is presses command one, when enter is pressed
    Code:
    Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
    Debug.Print KeyCode
    If KeyCode = 13 Then
    KeyCode = 35
    Command1.Value = True
    End If
    End Sub

  4. #4
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    It is quite easy. Simply test for the enter key (13) and set keyascii = 0, then call the command1_click event

    Code:
    Private Sub Text1_KeyPress(KeyAscii As Integer)
        
        If KeyAscii = 13 Then
          KeyAscii = 0
          Command1_Click
          'or Command1.Value = True
        End If
        
    End Sub
    Iain, thats with an i by the way!

  5. #5
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    i had the same as iain
    Code:
    Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
    KeyAscii = 0
    Command1.Value = True
    End If
    End Sub
    but where i stuffed up, was inside the command1_click code,
    i had a msgbox event, which makes a beep sound,
    so iain's version does not make a beep, unless it is raised in the command button's code.

    but why does this not work with keycode, is it because the textbox has already intercepted the call for that character?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width