Solved

Another VFP focus question/problem

Posted on 2010-09-16
9
737 Views
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)
      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!
0
Comment
Question by:cafulford
  • 4
  • 3
  • 2
9 Comments
 
LVL 4

Expert Comment

by:wcsoctu
ID: 33695118
Number 3 is:
ThisForm.txt_Search_deliv.Value='' before the SeFocus line
0
 
LVL 4

Accepted Solution

by:
wcsoctu earned 250 total points
ID: 33695576
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
 
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.
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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.
0
 

Author Comment

by:cafulford
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...
0
 
LVL 29

Expert Comment

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

Author Comment

by:cafulford
ID: 33712016
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
 

Author Comment

by:cafulford
ID: 33712020
Also, let me know if you want me to open up another ticket so points can be awarded...
0
 
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.
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

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://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

825 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