Solved

Another VFP focus question/problem

Posted on 2010-09-16
9
734 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
 
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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 your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Moving applications to the cloud or switching services to cloud-based ones, is a stressful job.  Here's how you can make it easier.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now