Sendkey {End} - not working for me (1 Viewer)

davesmith202

Employee of Access World
Local time
Today, 07:39
Joined
Jul 20, 2001
Messages
522
I have the following code that is triggered when I click a command button:

Code:
TopicBody = Town & " "
DoCmd.GoToControl "TopicBody"
Pause 1
SendKeys "{End}"

When I click the button, it goes to the TopicBody field (memo) and puts the value in (e.g. "London ") and the value is highlighted. Then it goes unhighlighted when the Sendkeys "{End}" kicks in.

When I do this manually on the keyboard it works. i.e. hitting End will go to othe end of the text in the TopicBody field. e.g. cursor is at end of "London ".

But when I do it in code it does not do this.

What am I doing wrong?

Thanks,

Dave
 

Rod D

Registered User.
Local time
Yesterday, 23:39
Joined
Feb 9, 2006
Messages
87
Hi Dave

Try
SendKeys "{End}",True

which will force the keystroke through.

Just a thought...
Regards
Rod
 

davesmith202

Employee of Access World
Local time
Today, 07:39
Joined
Jul 20, 2001
Messages
522
That didn't do it either. Really odd!
 

Rod D

Registered User.
Local time
Yesterday, 23:39
Joined
Feb 9, 2006
Messages
87
OK - Plan "B"

I tried your code and noticed that if the field contents were highlighted, the focus stayed on the button - not the memo field.

I ended up changing the {End} to {F2} (edit field) and it worked, so give it a go. I THINK the reason is because the {End} key is being treated as a "go to next object" key....?

See how you go.
Regards
Rod
 

Users who are viewing this thread

Top Bottom