Enter key/CR behavior on ActiveX control

Posted on 1999-06-24
Medium Priority
Last Modified: 2008-03-10
I'm using the following function such that the enter key would behave just like the tab key, allowing users to move from one textbox to another.

If KeyAscii = 13 then
 KeyAscii = 0
 CRToTab = True
 SendKeys "{TAB}", wait:= True

I call this function on the Keypress event of the textbox. However, when I hit the enter key, it leaves a vertical line trail mark on the textbox. It does this as the cursor blinks and the vertical line is showing.

I tried replicating this on an ordinary form and this weird behavior doesn't happen. When I launch my User Document on a web browser, it happens.

Question by:minime
  • 2
LVL 10

Accepted Solution

viktornet earned 100 total points
ID: 1519543
try this....

use the SendMessage() Win32 API... here is an example...

in OnKeyPress() do this....

call SendMessage(Form1.hWnd, WM_NEXDLGCTL, 0, 0)

this will move to the next control on the form...

LVL 10

Expert Comment

ID: 1519544
oppps, i see a little typo in the above message ;-))

call SendMessage(Form1.hWnd, WM_NEXDLGCTL, 0, 0)

should've read

call SendMessage(Form1.hWnd, WM_NEXTDLGCTL, 0, 0)

the WM_NEXTDLGCTL was misspelled...


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question