Text Box And enter key

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rojo
    New Member
    • Oct 2007
    • 5

    Text Box And enter key

    Hi

    I have a small database program in VB6, There is a form that has a command button that is labled "Search" and a text box for data base catalogue number user input.
    My problem is that when the keyboard enter key is pressed nothing happens, you allways have to click the search button before the batabase will find the number entered in the text box
    I think I have overlooked something simple, most likely in the properties somesware....Ca n some one help?
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Hi,

    "Tab" key is the default key which will moves to Next Control in the Tab Index.
    Set this property of the Commad button :
    Default = True

    Regards
    Veena

    Comment

    • Rojo
      New Member
      • Oct 2007
      • 5

      #3
      Veena,

      What i meant was ......to have both the enter key and the command button respond to the user, either hit the enter key or click the command button in which case both will work.

      Regards

      Rob

      Comment

      • QVeen72
        Recognized Expert Top Contributor
        • Oct 2006
        • 1445

        #4
        Hi,

        OK, Make Form's Property : KeyPreview=True
        and Write this is Form_KeyPress Event :

        [Code=VB]
        If KeyAscii = 13 Then
        Call Command1_Click
        End If
        [/code]

        Regards
        Veena

        Comment

        • Rojo
          New Member
          • Oct 2007
          • 5

          #5
          Veena

          Your solution works fine, Many thanks.

          Regards
          Rob

          Comment

          Working...