argh... SendKeys hell

  • Thread starter pubdude2003 via AccessMonster.com
  • Start date
P

pubdude2003 via AccessMonster.com

I have a simple calculation form wherein I would like to trap a "/", "*", "-"
or "+" then move the focus to the next control and then insert the trapped
keystroke... I have been using the code below but it is a bit 'blinky' always
tabbing but not always executing the second SendKeys, I guess as with all
SendKey code... you writes the code and you takes your chances.

Has anyone a bettter solution for me please?

Select Case KeyCode
Case 111, 191 'Divide
KeyCode = 0
SendKeys "{tab}"
SendKeys "/"
Case 106 'Multiply
KeyCode = 0
SendKeys "{tab}*"
Case 107 'Addition
KeyCode = 0
SendKeys "{tab}{+}"
Case 109, 189 'Minus
KeyCode = 0
SendKeys "{tab}{-}"
End Select
 
R

ruralguy via AccessMonster.com

As you have discovered, SendKeys is not a very reliable way to do things.
What type of control is the "next" control?
 
P

pubdude2003 via AccessMonster.com

thanks ruralguy

it's a simple text box, single character text field with the validation rule
set to
Like "*" Or Like "/" Or Like "-" Or Like "+" Or Like ""
 
R

ruralguy via AccessMonster.com

I have not tried it but since you know the character, why not just put it in
the TextBox and set the focus wherever you want. Bypassing the validation in
this case is not an issue. Or am I missing something?
 
P

pubdude2003 via AccessMonster.com

something like

Case 111, 191 'Divide
KeyCode = 0
Me.hiddensym1 = "/"
DoCmd.GoToControl "2"
End select

Why that makes too much sense for a fella like me! :)
Of course, a nice simple solution...

thanks ruralguy (btw how rural are you?)
 
R

ruralguy via AccessMonster.com

40 minutes from the nearest town.
something like

Case 111, 191 'Divide
KeyCode = 0
Me.hiddensym1 = "/"
DoCmd.GoToControl "2"
End select

Why that makes too much sense for a fella like me! :)
Of course, a nice simple solution...

thanks ruralguy (btw how rural are you?)
 
R

ruralguy via AccessMonster.com

Glad I could help. It is very quiet and dark where I live. We love it and
the turkeys, deer, bob cats, bear and tons of birds of all kinds.
 
L

Larry Daugherty

It seems you have found a different solution for your SendKeys issue.
However, if you run into situation where SendKeys seems to be the only
way you might want to use the fSendKeys laid out at
www.mvps.org/access It is a much safer form that overcomes some of
the issues with the function provided with Access.

HTH
 
P

pubdude2003 via AccessMonster.com

thanks Larry... I am not loathe to using it to automate some of the more
mundane chores I have like making mde's and such

I will take a look, particularly as just lately none of my sendkeys code
seems consistant... up til today it's been pretty steady but even my 5 step
macro to make an mde is failing... odd
 
T

Tony Toews [MVP]

pubdude2003 via AccessMonster.com said:
but even my 5 step
macro to make an mde is failing...

Ah, make an MDE?

You can automate MDE creation with the Application.RunCommand method,
using acCmdMakeMDEFile as the argument, either in code or with a
macro.

Or use SysCmd 603, "CurrentMDBName.MDB", "MDEName.MDE" That might
work only in A97 but I think it works in most versions.

Tony

--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
T

Tony Toews [MVP]

pubdude2003 via AccessMonster.com said:
I will take a look, particularly as just lately none of my sendkeys code
seems consistant... up til today it's been pretty steady but even my 5 step
macro to make an mde is failing... odd

So what else are you using SendKeys for besides your original question
and the make MDE? We may know of other work arounds.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
P

pubdude2003 via AccessMonster.com

Hey Tony, thanks you've been very helpfull in the past!

Actually it's just a 5 step macro using SendKeys to instruct an Access MDB to
make an MDE of itself.

DoCmd.Close acForm, "MakeMDE"
SendKeys "%T", False
SendKeys "D", False
SendKeys "M", False
SendKeys "~", False

It's really odd, SendKeys has never been much of an issue, but suddenly just
not working.
 
T

Tony Toews [MVP]

pubdude2003 via AccessMonster.com said:
Actually it's just a 5 step macro using SendKeys to instruct an Access MDB to
make an MDE of itself.

Right. I gave you two non SendKeys alternatives for that. But
nothing else then?

As far as it not working I have no idea. Do you have a form with a
timer?

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top