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

Using _curobj and objnum() 4

Status
Not open for further replies.

bigj

Programmer
Apr 12, 2000
7
CA
I am trying to move the cursor from a button to a txtfield if a certain condition is not true. In Fox 2.6 I could use _curobj = objnum(object#)
I have tried using code like thisform.activecontrol.tabindex = THISFORM.txtprod_id.tabindex without any success.
I used tabindex as per Language Reference page# 16 VisFox 6.0.
Could some help me with the correct code to implement what I am trying to do.
 
Hi;

Use the SetFocus method.

IF Something = SomethingElse
TextBox1.SetFocus()
ELSE
TextBox2.SetFocus()
ENDIF

Hope this helps

Ed Please let me know if the sugestion(s) I provide are helpful to you.
Sometimes you're the windshield... Sometimes you're the bug.

 
Just a couple notes:
1) You can't use setfocus() in a VALID() or WHEN() method - this includes anywhere in the call stack. (i.e. A VALID() starts another form, which has a SETFOCUS() in a CLICK() method won't work!)
2) If you use it in a LOSTFOCUS(), make sure to include a NODEFAULT, or the default will just reset the focus to the next field in the tab order.

Rick
 
There are two ways to do what you're looking for: one is in the LOSTFOCUS event, the other is in the VALID event.

The LOSTFOCUS event is easier to implement. Simply put an IF statement in to check your condition and call the SETFOCUS() method on the control you want to move to.

To do it from the VALID event, put your IF statement in again. However, instead of calling SETFOCUS(), which will cause an error, simply RETURN a number. That number is the number of TAB stops to move the focus. So, if you want to skip the next 5 controls if the value entered is "YES", you would do this:
Code:
PROCEDURE Valid
IF this.value="YES"
    RETURN 5
ENDIF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top