Results 1 to 13 of 13
  1. #1
    JamesAnderson1984 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    5

    SendKeys works on rare occasions in Access 2010

    Not sure if this question has been asked already. I searched and so far have found nothing. I built an application in Access 2007 on a Windows 7 machine. I used VBA for all the coding. I am now running it in Access 2010 on a Windows XP machine. I have a line of code that reads: SendKeys "^{ENTER}". It allows me to open a macro I select from a listbox. It works perfectly in 2007 but not 2010. I am wondering if this is a computer and OS issue or an Access version issue. Any ideas?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    Should be able to call a macro from VBA code. Why do you need the SendKeys? SendKeys is supposed to be bad programming. I have resorted to it for one situation because couldn't figure out anything else. http://access.mvps.org/access/tencommandments.htm
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    JamesAnderson1984 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    5
    I have read everywhere that SendKeys is bad programming, but I still need to use it. The code tells access to open the macro in design view, not run a macro. So, calling a macro is fortunately not the problem. I developed a form to use as a navigation pane when I have large amounts of objects in my databases. It makes for easier scrolling and quicker searches of objects. That VBA code is, unfortunately, the only one I have found that will open a macro in design view. Like I said, it works flawlessly in 2007 but seem to have issues in 2010. But it could also be the fact that I developed it on a newer computer and I'm trying to run it on an older computer.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    Okay, more questions. Why need to open macro in design view? Why use macro? Won't work on any machine with Access 2010? Want to provide db for testing? Follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    PATRICK is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Apr 2011
    Posts
    32
    James, if you really wants to use sendkeys you have to place it in a label and the syntax should be:

    SendKeys "{ENTER}" or SendKeys "~"

    It should do the job.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    Patrick, I don't understand what you mean by 'place it in a label'. Only place I have used SendKeyes is in VBA procedure.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    PATRICK is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Apr 2011
    Posts
    32
    hey June, im not sure how/where he's going to use the sendkeys, but if he needs it in the form for example, and do this in a command button, the command you do the code but will get the focus, so let's say he has a numeric keyboard is better to have label numbers instead button, label will not hold the focus...but you can have it in procedure ofcourse. by the way, did you have a chance to go back to the website where I was trying to get the data from?

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    Sorry, still don't understand the label idea.

    I will try visiting your issue this weekend.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    PATRICK is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Apr 2011
    Posts
    32
    ok like I said I'm not sure where he's going to use the sendkeys. but I'll explain the label idea:

    lets say you're building a numeric keyboard touch for password check ok? so you are going to have 0 to 9 buttons and one text box. if I use the buttons to send the numbers to the text box (sendkeys "1") it will send it but then the focus will remain in the cmdbutton number 1, then if I click to send number 2 on cmdnumber2 button it will not send until I put the setfocus back to the text box right, or otherwise it will send (sendkeys "2") to the button because it has the focus and it just going to give a error... anyway is better to have this keyboard number 0 to 9 in a label because when I touch the label number 1 will send (sendkeys "1") and the focus will remain in the text box, so I can just click on the others...

    looking forward to hear back from you about the data from website... thanks.

  10. #10
    JamesAnderson1984 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    5
    SendKeys "^{ENTER}" is CTRL + ENTER. I want to be able to open up the macro and edit it. I don't want to have to scroll through the navigation pane just to find macros and then right-click open in design view. That's why I want to open a macro from my form! I can post the db here if you want to take a look at it. I've only run it on 2 computers as stated in the first post. It works on one but not the other. Not a huge deal, just a slight inconvenience.NavPane Form.zip

  11. #11
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    Your macro has no code in it. I added MsgBox code. Now the SendKeys works. The macro opens in design view.

    Interestingly, manually clicking to select macro then pressing Enter key causes the macro to execute.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    JamesAnderson1984 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    5
    Quote Originally Posted by June7 View Post
    Your macro has no code in it. I added MsgBox code. Now the SendKeys works. The macro opens in design view.

    Interestingly, manually clicking to select macro then pressing Enter key causes the macro to execute.
    All objects are dummy objects to check if the vba was working. So, of course the macro had no code. If it works only after you enter code in the macro then that will do the trick. But, I know it worked for a moment yesterday without code in the macro. It runs without fail on my laptop at home.

  13. #13
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    I tested on laptop running Windows 7 Home Premium SP1 and Access 2010.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 12-03-2012, 05:28 PM
  2. Replies: 1
    Last Post: 06-26-2012, 10:02 PM
  3. Replies: 1
    Last Post: 06-21-2012, 07:58 PM
  4. Replies: 4
    Last Post: 05-18-2012, 06:07 PM
  5. Replies: 3
    Last Post: 03-15-2012, 03:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums