How to make a Label Box act as Enter Key on click?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • slenish
    Contributor
    • Feb 2010
    • 283

    How to make a Label Box act as Enter Key on click?

    Hello everyone,

    Not sure if I made my question header very clear but not sure how else to word it so i appoligize to the admins in advance.

    What I have is a form where I have one text box for keying in a word and then I have a save button. The save button i made is not a button but a label that saves the information on click. The problem I'm having is if you key information in to the text box and then press the save label button it will not save, but if you key in information in to the text box then press the Enter key and then press the save button it works. Is there anyway i can get the save button to act as the Enter key press on the text box first before it saves??

    I have been trying to use the KeyAcsii(13) function in the OnClick command but so far im getting no luck. Also the form is Unbound.

    Any help would be great!

    Thanks in advance,

    Slen
  • Michael Brown
    New Member
    • Jan 2011
    • 6

    #2
    Hi Slen,

    I don't why you would want to use a label as a button but I'm sure you have a reason :-)

    I think the reason that the OnClick command isn't working is because as you click on the label, you're losing focus from the text box.

    Would it be possible to create an invisible command button and have the label OnClick activate it?
    Or place a transparent command button in front of the label?

    - Michael

    EDIT: To get around the focus problem you could also assign the KeyAcsii(13) function to the OnMouseMove command for the label, I believe it's similar to MouseOver

    Comment

    • slenish
      Contributor
      • Feb 2010
      • 283

      #3
      Hi Michael,

      Thanks so much for the reply,

      actually i figured out how to make it work. You are right that once I would click on the label it would take focus away from the Text box so what i did was I added in the command [Me.Refresh] at the beginning of my code when you click on the save (label) button, and now it works.

      Thanks again for the reply appreciate the help :D

      Comment

      Working...