Tags: access, click, converted, database, field, function, highlight, keys, microsoft, mysql, oracle, sendkeys, sql

Highlight Field on Click for Editing (F2)

On Database » Microsoft Access

4,784 words with 10 Comments; publish: Fri, 04 Jan 2008 21:09:00 GMT; (25046.88, « »)

I have an Access 97 database that when converted to Access 2007 everything seems to work except for the Send Keys function. I have a sendkeys function on the on-click action in a form that sends F2 which highlights the entire field so that it can be completely overwritten as opposed to the normal behavior of just inserting a cursor for editing. Is there a work around for this?

Thanks,

Rob

All Comments

Leave a comment...

  • 10 Comments
    • Good morning, and welcome to the Scripts!

      Converting from Access 97 to 2007 isn't a task for the faint of heart :-)

      Allen Browne's website here Acesss Tips: Converting to Access 2007 is an excellent resource including links to other very good resources.

      That said, I'm not sure about the send-keys function, but I believe I've seen a thread on that somewhere here. Let me take a look and get back to you.

      Regards,

      Scott

      #1; Fri, 04 Jan 2008 21:11:00 GMT
    • This is a link to MS website with a discussion of Access 2007 sandbox mode. Apparently the sandbox mode will restrict the availability of a number of functions, among which is SendKeys. It will result in an error when called from VBA. http://office.microsoft.com/en-us/a...2301901033.aspx

      As far as a solution, that depends on your application. One developer's advise is to always develop your applications for the maximum level of security restrictions that will be imposed by Access: in other words don't look for a way to make it work by lessening the restrictions, look for a way to re-design so as to not infringe the security imposed by sandbox mode.

      That said, again depending on your application requirements, you could explore resetting the sandbox mode to a lower level to see if that will allow the SendKeys to work.

      Regards,

      Scott

      #2; Fri, 04 Jan 2008 21:12:00 GMT
    • Thanks for the reply...,well let's forget about security and sandbox rules. What if I was writing a brand spanking new DB in Access 2007? How do I accomplish the following. I have a Order Entry Form with certain text box fields that when clicked I want to completely highlight, so a single keystroke will erase the the existing data enabling to input new data. It is what hitting F2 will do, but I don't want the user to have to hit F2. As opposed to do the default of clicking the text box field and the insert cursor blinking at the point of click. Maybe a "Select all" function? How do I program this under the "OnCLick" function?

      Thanks,

      Rob

      #3; Fri, 04 Jan 2008 21:13:00 GMT
    • Quote:=== Original Words ===

      mktwhseThanks for the reply...,well let's forget about security and sandbox rules. What if I was writing a brand spanking new DB in Access 2007? How do I accomplish the following. I have a Order Entry Form with certain text box fields that when clicked I want to completely highlight, so a single keystroke will erase the the existing data enabling to input new data. It is what hitting F2 will do, but I don't want the user to have to hit F2. As opposed to do the default of clicking the text box field and the insert cursor blinking at the point of click. Maybe a "Select all" function? How do I program this under the "OnCLick" function?

      Thanks,

      Rob

      This code works fine in the On Click event of a text box in Access 2003. Give it a try:Code: ( vb )

      1. Me!Text1.SelStart = 0
      2. Me!Text1.SelLength = Len(Me!Text1.Text)

      You'll need to rename Text1 to the name of your text box.

      Regards,

      Scott

      #4; Fri, 04 Jan 2008 21:14:00 GMT
    • Alternatively try :

      Tools / Options / Keyboard / Behavior entering field ==> Select entire field.

      This is a per PC (installation of Access) approach mind you, but may be easiest. It may even be possible to force using code within a database but I don't know the code if it is.

      #5; Fri, 04 Jan 2008 21:15:00 GMT
    • Thanks for the responses, I'll the try the SelLength code tomorrow. I appreciate the other response regarding the setting per pc, I knew about that, but I don't want the behavior on all fields.

      Thanks,

      Rob

      #6; Fri, 04 Jan 2008 21:16:00 GMT
    • This works great for text box, but shouldn't it work for a combo box as well. I can't seem to get it to work on a combo box.

      Randy

      #7; Fri, 04 Jan 2008 21:17:00 GMT
    • Why would you want to select the text in a combobox?

      Linq ;0)>

      #8; Fri, 04 Jan 2008 21:18:00 GMT
    • Quote:
      === Original Words ===

      This works great for text box, but shouldn't it work for a combo box as well. I can't seem to get it to work on a combo box.

      Randy

      It shouldn't, no.

      It would make little sense for it to work that way in a ComboBox.

      #9; Fri, 04 Jan 2008 21:19:00 GMT
    • I have a combo box set up to either select from existing text or add new text.
      #10; Fri, 04 Jan 2008 21:20:00 GMT