Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting focus on a new control 1

Status
Not open for further replies.

zggs90

Programmer
Sep 3, 2001
58
GB
I have built a control that is basically a text box with limits that control the characters that can be entered, in this case it is only numeric data.

When I load the form that contains the new component I try to set the focus to new control with

NewControl1.SetFocus

but I get a runtime error 5, invalid procedure call or argument,

when I use a regular textbox and code

TextBox1.SetFocus

it works fine.

Any help on what is needed ?

 
Double check all the code in your control. It sounds like you might have a typo somewhere.
 
Thanks for your response, I have checked the code and it appears OK.

I am able to use the control normally, it is only trying to set focus when the problem occurs.
 
Does your control have the SetFocus method listed as a method of the new control?
If it does, is there any code in this method?
 
Move the .Setfocus out of Form_Load to the Form_Activate event

[flowerface]

"All I ask is the chance to prove that money can't make me happy." - Spike Milligan
 
tb thanks for your sugestion on moving from Load to Activate it worked fine.

Many thanks to the others who contributed.
 
Schweeeeeet !
[flowerface]

"All I ask is the chance to prove that money can't make me happy." - Spike Milligan
 
Thnx !
:)

"All I ask is the chance to prove that money can't make me happy." - Spike Milligan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top