devxlogo

Illegal SetFocus Call

Illegal SetFocus Call

Question:
Sometimes when I call

Text1.SetFocus
it returns me an “Illegal function call” error. Any idea why?

Answer:
Normally, if the Form is not visible, you can’t call SetFocus to it. I would imagine you get this error when you call this code from Form_Load. The control is not available at that point in the application load process.

devx-admin

Share the Post: