Consulting

Results 1 to 12 of 12

Thread: SendKeys Not Working

  1. #1
    VBAX Regular
    Joined
    Feb 2007
    Posts
    13
    Location

    SendKeys Not Working

    Why does this not work

    [VBA]
    Private Sub MPN_Click()
    Application.FollowHyperlink ("http://www.scif.com/MPN/MPNsearch.html")
    AppActivate ("Microsoft Internet Explorer"), 1
    SendKeys "{TAB 20}", True
    SendKeys Me.ZIP, True
    SendKeys "{TAB}", True
    SendKeys " ", True
    SendKeys "{TAB}", True
    SendKeys "O", True
    SendKeys "{TAB 3}", True
    SendKeys "{ENTER}", True
    AppActivate ("Microsoft Access"), 1
    End Sub
    [/VBA]

  2. #2
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Because SendKeys is one of the most flaky things in VBA.

    I would suggest you look into automating IE from VBA.

    It looks to me as though all your doing is filling in the zip code field, and some other fields and then submitting the form.

    All that can easily be done using automation

  3. #3
    VBAX Regular
    Joined
    Feb 2007
    Posts
    13
    Location
    Quote Originally Posted by Norie
    Because SendKeys is one of the most flaky things in VBA.

    I would suggest you look into automating IE from VBA.

    It looks to me as though all your doing is filling in the zip code field, and some other fields and then submitting the form.

    All that can easily be done using automation
    I agree with the sendkeys being flaky - I am just trying to add the zip from an access form select initial treatment provider radio button, select occupational medicine from the pulldown then enter to submit the search

    Not sure where to start... I think I read something or saw a resource in here where someone had filled in a hotmail login form - maybe you did it

  4. #4
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Not sure if I've worked with hotmail logins - not sure that I would in fact due to the security implications.

    But I've definitely done some stuff with automating IE.

    I'll take a look at the URL you posted in your code and try and post back.

    The challenge with this type of thing is that you need to look at the pages HTML source code to figure things out.

    And that isn't always simple.

  5. #5
    Administrator
    2nd VP-Knowledge Base
    VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    Quote Originally Posted by imatte
    Not sure where to start... I think I read something or saw a resource in here where someone had filled in a hotmail login form - maybe you did it
    Maybe it was me

    This thread is where I started logging into Gmail.
    In this thread (post #3) is where I updated the procedure.

    If this wasn't what you were talking about then my apologies




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  6. #6
    VBAX Regular
    Joined
    Feb 2007
    Posts
    13
    Location
    Quote Originally Posted by malik641
    Maybe it was me

    This thread is where I started logging into Gmail.
    In this thread (post #3) is where I updated the procedure.

    If this wasn't what you were talking about then my apologies
    Yes, that's what I read... I knew I saw something somewhere. At first glance it looks pretty overwhealming, I will have to take some time and read the posts.

  7. #7
    Dear colleagues,
    I am new to this forum, and I joined after searching for a solution to the (well known, as I see) problem with SendKeys.
    Now this seems to be a rather tricky thing, but I use it for one thing only.
    A table has unique keys (e.g. the combination of name and date must be unique), and I import data from another source with an append query. I want to be able to do this each time I open the form, and I want to suppress the message "X records cannot be appended due to ...": this way Access will only append "new" data en leave the old ones.
    Now is there any other simple way or command to do this, in the sense of "append only those records which are not yet in my table"?
    Thank you in advance!
    Zisdienst

  8. #8
    VBAX Expert
    Joined
    Oct 2012
    Posts
    726
    Location
    Add currentdb.execute "YourAppendQuery" to the forms open event.

  9. #9
    Can you elaborate a bit more on this? What does it do "in human language"?

  10. #10
    VBAX Expert
    Joined
    Oct 2012
    Posts
    726
    Location
    "YourAppendQuery"

    The name of the query you want to run. Or alterantively a SQL string.

    execute

    Execute (run) the query against the database...

    currentdb

    You can open a connection to any database you like. Currentdb is an easy way of referring to the database file currently open in Access.

    So, the code says “execute this query (or sql statement) against the database open in Access.”


    Forms, reports, databases, controls are objects. When something happens to an object (it is opened, closed, clicked, etc) it is known as an event.
    You can add code to events to make something else happen.

    You said you want to run the query every time you open a particular form.

    So you would put the code in the form code module's open event.

    In the module you should see two dropdown boxes above the code.
    The left one lets you select an object (in this case "Form") and the other lets you select the available events that you can capture.


    Private Sub Form_Open(Cancel As Integer)
        CurrentDb.Execute "delete * from table1"
    End Sub

  11. #11
    OK, I see.
    But the main problem is not how to import - that part works, except for the dialog box which needs a "yes"-click - but how to prevent double import, because the source table must not be flushed (it is in fact a read-only table in an Oracle database), so the same records will be presented over and over again.
    BTW, I am aware of the fact that I'm a very low-level-VBA-user: I hardly know any code, and I am limited to generating code with wizards and then adjusting them where needed. That's why my "SendKeys"-solution was so useful!
    It strikes me as very, very odd that this command fails all of a sudden, on all of our clients and in all of my Access-databases. The message is "Run time error: permission denied" (and not a syntax error, but of course Sendkeys "Y" is right!). Any idea which parameter can cause this?

  12. #12
    VBAX Expert
    Joined
    Oct 2012
    Posts
    726
    Location
    Somebody else will have to help you with that.
    I wouldn't use sendkeys for anything and have no interest in experimenting with it.

Posting Permissions

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