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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setFocus problem..

Status
Not open for further replies.

tviman

Programmer
Jul 25, 2002
2,123
US
I've created a form in MX that has several text fields and combo boxes. As part of a validation routine, I check to see that certain fields contain data and if it doesn't, I present the user with an error message telling that such and such field needs to be filled in. When the user clicks the "back" button I have provided, they are returned to the frame that contains the text fields. So far, no problems.

It would be really nice to be able to place the cursor in the proper text field. I have used the following:

selection.setFocus("varname");
selection.setFocus("field_instance");
selection.setFocus("field_instance.varname");
selection.setFocus("clip_instance.field_name");
selection.setFocus("clip_instance.varname");
selection.setFocus("_root.varname");
selection.setFocus("_root.clipinstance.varname");
selection.setFocus("_root.clipinstance.field_name");

All that happens is the text in the first field on the form is highlighted. Has anybody run across this before and if so, did you reach a solution?

There's always a better way. The fun is trying to find it!
 
Thanks oldnewbie, but I think I may not have explained my problem correctly.

When I return from the "Fill in the field" frame, I want to set the focus on the offending field. I have tried to set the focus using one of the following, none of which works.

selection.setFocus("varname");
selection.setFocus("field_instance");
selection.setFocus("field_instance.varname");
selection.setFocus("clip_instance.field_name");
selection.setFocus("clip_instance.varname");
selection.setFocus("_root.varname");
selection.setFocus("_root.clipinstance.varname");
selection.setFocus("_root.clipinstance.field_name");

From your link, it seems that there is a conflict with what Macromedia says should work and what works in reality. I'd be happy to find ANY method that works. I guess the only syntax I haven't tried is:

selection.setFocus("_root._clipinstance.varname");
or
selection.setFocus("_root._clipinstance.field_name");

It doesn't make sense that this would work but then again, this is appears to be a poorly documented feature so "why not"?

I'll get back shortly with the results.

Thanks for your help...

There's always a better way. The fun is trying to find it!
 
Can you post a link to your .fla or a small mockup one, replicating the problem? Zipped up and in MX only format.
 
Hi all,

I have a form (frmJobSummary) with a subform (subfrmProduct). On this subfrm I have a combo box (cboTransport).

When I open this form, I would like the cursor to be sitting in the combo box.

I have tried the following code in the onload event of the form:
Private Sub Form_Load()
Forms!frmJobSummary!subfrmProduct.cboTransport.SetFocus
End Sub

It doesn't seem to work. Does anyone have any ideas?

Thanks in advance.
 
I think I might have posted the above post in the wrong forum. I will repost in the forms forum.


Sorry guys.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top