View Full Version : SendKeys Not Working
imatte
03-13-2007, 06:42 PM
Why does this not work
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
Norie
03-14-2007, 11:48 AM
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
imatte
03-14-2007, 01:21 PM
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 :)
Norie
03-14-2007, 01:30 PM
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.:)
malik641
03-14-2007, 04:15 PM
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 (http://www.vbaexpress.com/forum/showthread.php?t=9810) is where I started logging into Gmail.
In this thread (http://www.vbaexpress.com/forum/showthread.php?t=11383) (post #3) is where I updated the procedure.
If this wasn't what you were talking about then my apologies :)
imatte
03-15-2007, 08:58 AM
Maybe it was me :)
This thread (http://www.vbaexpress.com/forum/showthread.php?t=9810) is where I started logging into Gmail.
In this thread (http://www.vbaexpress.com/forum/showthread.php?t=11383) (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.
zisdienst
05-04-2015, 02:52 AM
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
Add currentdb.execute "YourAppendQuery" to the forms open event.
zisdienst
05-06-2015, 05:31 AM
Can you elaborate a bit more on this? What does it do "in human language"?
"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
zisdienst
05-06-2015, 08:42 AM
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?
Somebody else will have to help you with that.
I wouldn't use sendkeys for anything and have no interest in experimenting with it.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.