Question Can not get focus

ideprize

Well-known member
Joined
Oct 19, 2011
Messages
97
Programming Experience
10+
Hi All - Happy late New Year

I have a working program that I want to add a textbox to in order to get some data from the user. The program does a lot of file processing on auto pilot - it is "called" in by a FoxPro program to use Excel to create a PDF form that is finally emailed. The users want to specify the body of email message so I said - "no problem"; multiline textbox! I added the textbox, set the tab index to 0; set the focus and started testing - processing never stops to allow the user to input. The control is enabled and I am doing a me.show because the processing status of the programming is displayed to the end user, etc. I have placed a msgbox in the textbox enter event - it pops; I have placed a message box in the textbox gotfocus event - it pops. I have placed a message box in the textbox leave event - it never pops. The gotfocus event message box pop of course locks the program up which to me implies it has focus but "can't use it. Obviously, I am missing something - any suggestions, insights would be greatly appreciated.

IDEPRIZE
 
I am answering my own post. I found out that during the main form load it was not possible to get focus of any of the controls. Once I transferred the guts of the code from the form load sub to a button_click sub the textbox took focus. Now if I can only figure out why I need a me.show with this single form program in order to get it to display - back to the drawing board.

IDEPRIZE
 
The Load event of a form is raised immediately before the form is displayed and the Shown event is raised immediately after. If you want to do something immediately after the form is displayed then you do it in the Shown event handler. Any code you put in the Load event handler will be executed before the form is displayed.
 
Thanks Jim for the formal definition and alternate solution. Just to make sure I was "understanding" your solution I checked the events under the form events and indeed found the "shown" event. This is good info for it means you can partition the form load code into "before and after". Again thanks Jim!

IDEPRIZE
 
Back
Top