Another VFP focus question/problem

Posted on 2010-09-16
Last Modified: 2012-08-14
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)
      IF NOT FOUND()
       Messagebox("No records found for the entered Delivery #, please try again.",0, "Assign Tracking Numbers")
*            ThisForm.txt_Search_deliv.SetFocus


Thanks again!
Question by:cafulford
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2

Expert Comment

ID: 33695118
Number 3 is:
ThisForm.txt_Search_deliv.Value='' before the SeFocus line

Accepted Solution

wcsoctu earned 250 total points
ID: 33695576
Not saying this is the best way, but:
In the LOAD
    PUBLIC  BackToDelivery

In the Valid of the delivery box, when you determine it is not found:

In the GotFocus of the next object:
IF BackToDelvery
LVL 29

Assisted Solution

by:Olaf Doschke
Olaf Doschke earned 250 total points
ID: 33695623
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.
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 29

Expert Comment

by:Olaf Doschke
ID: 33699681
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.

Author Comment

ID: 33700721
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...
LVL 29

Expert Comment

by:Olaf Doschke
ID: 33704552
Don't bother, the closing will be done automatically, it'll just be happening delayed.

Author Comment

ID: 33712016

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?



Author Comment

ID: 33712020
Also, let me know if you want me to open up another ticket so points can be awarded...
LVL 29

Expert Comment

by:Olaf Doschke
ID: 33712192
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.

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: (http://msd…
This article outlines some of the reasons why an email message gets flagged as spam on a recipient's end.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question