ibbm


Going back to the olden days I used to be able to move my cursor by using the code _curobj = _objnum(myfield)

How do I do this in Fox 6 What I am trying to do is at the click of the command button, clear my screen and start the user on the first or second field depending on what he is doing.

Thanks in advance.




Re: how to set focus (or place the cursor) on a field in a form using code...

dni


In vfp 6 are you using a form or "on screen" How do you show fields







Re: how to set focus (or place the cursor) on a field in a form using code...

Markish

Hi,

You can use 'setfocus' method to position your focus in particular object. In your case, in the click method of command button write something like

Code Snippet

if (some condition)

thisform.text1.setfocus

else

thisform.text2.setfocus

endif

Best regards,

Markish







Re: how to set focus (or place the cursor) on a field in a form using code...

Naomi Nosonovsky

You can use object.SetFocus()

If you want to move to a specific field from the Valid event, return the number corresponding to the difference in tab sequence.

Say, if you want to go to the previous field you would use return - 1. Return 0 will not let you leave the field.





Re: how to set focus (or place the cursor) on a field in a form using code...

ibbm

When I try try this it says Cannot setfocus within a When Valid RangeHigh event.





Re: how to set focus (or place the cursor) on a field in a form using code...

ibbm

I am using a form and when the user clicks on the save order I want the form to be cleared and the cursor to be in the first textcontrol to start entering a new record.





Re: how to set focus (or place the cursor) on a field in a form using code...

Naomi Nosonovsky

Check Help on Valid event. You can not call SetFocus() from certain methods, in Valid in particular. Where did you try to put your code





Re: how to set focus (or place the cursor) on a field in a form using code...

ibbm

under the click event of the save button





Re: how to set focus (or place the cursor) on a field in a form using code...

Naomi Nosonovsky

Was the button's click called from some other method

Otherwise it doesn't make much sense. If there is a button on the form, you should be able to call textbox.SetFocus() from it. Make sure you put the code in button's click and you're just clicking on the button and not calling its click from somewhere else.





Re: how to set focus (or place the cursor) on a field in a form using code...

ibbm

This is the code in the click event and it is not called from anywhere.

if Thisform.ocstatusflag = "TO"
scatter name ThisForm.oNewRecord memo blank
WIth thisform
.oNewRecord.Orderdate = date()
.oNewRecord.Ordertime = time()
.oNewRecord.Agent = m.agnumber
.oNewRecord.statusflag = "TO"
.oNewRecord.branch = ThisForm.ocBranch
.oNewRecord.clientcode = ThisForm.ocClientcode

Endwith
ThisForm.Refresh
ThisForm.txtsecuritycode.setfocus
else
ThisForm.Release
endif





Re: how to set focus (or place the cursor) on a field in a form using code...

Tamar E. Granor

Is it possible that the form itself was called from a Valid of a control on another form

In general, in VFP, a lot of what you used to do in Valid belongs in either InteractiveChange or LostFocus.

Tamar




Re: how to set focus (or place the cursor) on a field in a form using code...

Naomi Nosonovsky

That's a bit weird then. Put a break point at the top of this code and try to see what exactly it's doing.





Re: how to set focus (or place the cursor) on a field in a form using code...

ibbm

Yes, you're right, the form was called from another form in a valid event. I switched to the valid event to the lostfocus event and it works!

Thanks so much and everyone else.





Re: how to set focus (or place the cursor) on a field in a form using code...

CetinBasoz

Now you found it outSmile For what it is worth do not use valid especially in grids. In fox2x they have been used heavily but in VFP probably the only place I use it is combo/listbox valid. Rest fits nicely to Lostfocus.

My 0.02 cents.