Another VFP focus question/problem

Thanks to you guys I have the form working, the colors the way I want in the grid and the horizontal scroll working but since I added the error message if there was not a hit on delivery # back in, I am having problems. I spent the last hour playing and can not figure out how to solve it.

Here are the 3 problems problem in the jpg.:

Tracking # screen

Here is the code I have in #1 (txt_Search_deliv). If I uncomment out the "ThisForm.txt_Search_deliv.SetFocus", I get an error that says: "Cannot call SetFocus from within a When, Valid, RangeHigh or RangeLow event."

Select Label

If NOT Empty(ThisForm.txt_Search_deliv.value)
      Set Filter To label.deliv_num = AllTrim(ThisForm.txt_Search_deliv.value)
      Locate
      IF NOT FOUND()
       Messagebox("No records found for the entered Delivery #, please try again.",0, "Assign Tracking Numbers")
*            ThisForm.txt_Search_deliv.SetFocus
    ENDIF
Endif

GO TOP
ThisForm.grdLabel.refresh()


Thanks again!
cafulfordAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
wcsoctuConnect With a Mentor Commented:
Not saying this is the best way, but:
In the LOAD
    PUBLIC  BackToDelivery
    BackToDelivery=.F.

In the Valid of the delivery box, when you determine it is not found:
     BackToDelivery=.T.

In the GotFocus of the next object:
IF BackToDelvery
     BackToDelivery=.F.
     thisform.txt_Search_Deliv.SetFocus
ENDIF
0
 
wcsoctuCommented:
Number 3 is:
ThisForm.txt_Search_deliv.Value='' before the SeFocus line
0
 
Olaf DoschkeConnect With a Mentor Software DeveloperCommented:
The error message is clearly saying what you can't do, so you can't do that. You forgot to mention but I know from your previous posts, that the line ThisForm.txt_Search_deliv.SetFocus actually is in the valid event of that textbox. You can instead RETURN 0 to stay in the textbox.

But you are causing a problem by this, if the user simply wants to close the form he can't unless a valid delivery # is entered. I would not recommend to put the effort into the automatic movement of the focus. As in any windows application you can use TAB to tab forward in controls and SHIFT+TAB to tab back. You can also add a hotkey by setting the caption of the button "Enter another delivery #" by setting the caption to eg "\<Enter another delivery #", this way The E of Enter will be underlined and ALT+E is a hotkey to "press" this button.

Then in the Click() event of that button you can put the Setfocus code and user can use ALT+E or, if the button has focus, use RETURN to enter another delivery number. Anyway the form can be used with keyboard ony, I see that needing to use the mouse is contraproductive for quickly entering tracking # for several delivery #, but I'd say that is sufficient already.

Bye, Olaf.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Olaf DoschkeSoftware DeveloperCommented:
This is an unusual close request. I don't see any reason for us to object about getting points assigned...Usually you make a close request, when you want a refund only.

Bye, Olaf.
0
 
cafulfordAuthor Commented:
I am not sure what happened. I just wanted to assign the points as usual. I am not sure how it was set up as a close request or how I can close it out as I usually do...
0
 
Olaf DoschkeSoftware DeveloperCommented:
Don't bother, the closing will be done automatically, it'll just be happening delayed.
0
 
cafulfordAuthor Commented:
Olaf,

One last question on this: If they click on #2 (for whatever reason before they entered anything in #1), it automatically shows all records in the label.dbf file. Is there a way to prevent any lookups if they click on #2?

Thanks,

Charlie
0
 
cafulfordAuthor Commented:
Also, let me know if you want me to open up another ticket so points can be awarded...
0
 
Olaf DoschkeSoftware DeveloperCommented:
That's simply because you have the code to filter the data in #1 Valid event. When focus is lost you filter, if no delivery # is entered the filter is se to an empty string which is fullfilled by all records due to the way foxpro compares strings. If you don't want that, have an extra case in the code setting the filter to a condition no record fulfills.

You don't need to open another ticket for this advice, thanks anyway.

Bye, Olaf.
0
All Courses

From novice to tech pro — start learning today.