Enter and DBEdit problem

I have a form with a couple of DBEdits, DBMemos and other DB controls. It is an edit form with a button which posts the changes to the edited record.
In OnKeyPress event I have the code to deal with Enter:

if(Key = #13) then
begin
  Key := #0;
  Perform(WM_NEXTDLGCTL, 0, 0);
end;

When Enter key is pressed on any DB control different than DBEdit the FormKeyPress is called and the next control is focused, but when the Enter is pressed on any of DBEdit controls the OnClick event of my button is called and I'm not able to say why it happens.

Thank you


shrlduAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

simonetCommented:
Set the FORM's KeyPreview property to true and make sure that the above code (the one oyu posted) is in the Form's OnKeyPress event, not in each component's OnKeyPress.

Yours,

Alex
0
men xinCEOCommented:
you connect some Dbedit's onenter event to your button's onclickevent handle?
0
shrlduAuthor Commented:
Simonet,
FORM's KeyPreview property _is_ set to true. The code _is_ in the Form's OnKeyPress event, not in _any_ component's OnKeyPress event. That's what make me crazy about the situation.

Menxin,
Non, I do not.

I can only add that all that is put on a page of a PageControl.


0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

men xinCEOCommented:
why do you not debug it with step over?
it can help you to find the reason.
0
shrlduAuthor Commented:
Well, I did. Immediately after pressing Enter key in any of my DBEdit controls I am in OnClick event of my button. That's the reason of my desperation. The worse is that it happens only on that one form - others, with similar set of components, work OK. One of the differences is that I have also ActionList on that form - but in no connection with Enter key or my button key, of course. Perhaps there is some side effect of my error but I have no idea how to get to it when the debugger simply takes me to OnClick event of the button instead of going to OnKeyPress event.
0
kretzschmarCommented:
hi shrldu,

if the default-property of this button is true,
then set it to false and try again.

meikl
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
shrlduAuthor Commented:
Hi Kretzschmar,

I'm ashamed having to tell that it was that. I'm going to accept your answer of course - could you comment, please, on why it works like that only in DBEdit, not in DBMemo, for instance?

Great thanks!
0
shrlduAuthor Commented:
Hi Kretzschmar,

I'm ashamed having to tell that it was that. I'm going to accept your answer of course - could you comment, please, on why it works like that only in DBEdit, not in DBMemo, for instance?

Great thanks!
0
DGNCommented:
If all else fails,

you can deactivate Button using OnEnter
of DBEdit and activate Button as last
step in OnKeyPress event.

I know, this is a really unusual idea,
but it could do what you want.
0
kretzschmarCommented:
hmm, a C-grade :-(

by a dbmemo, i guess, a enter key is normally send to it  to perform a line-break in the memo-text
(i guess this will be never possible now)

glad to helped you ;-)

meikl
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.