Solved

Visual Foxpro 6 - focus and grid question

Posted on 2010-09-15
6
1,488 Views
Last Modified: 2012-05-10
Hi again, I am working on a twist to a program I was working on last week with help from various ee members. This time, I have been asked to do something a little simpler. I have it working but I have a couple of questions.

In a nutshell the program is meant to allow the user to enter tracking #'s for all records of a particular delivery. Each record will have a different tracking # in this case as follows:

The user enters a delivery # in #1 and all records for that delivery are displayed in the grids of #2. The 1st grid only contains the tracking # and the 2nd grid (read-only, no tab focus) displays a little more info for the user for each record.

My questions are:

1) After they enter the delivery #, I have the tab set focus on the 1st grid (enter tracking #) grid in #2 (see image). Is there a way to have it automatically move to the next cell in the grid after they hit enter to make entry easier? Right now, they have to click on the next cell after they get done entering the tracking # for the current cell.

2) If no delivery # is found in #1, how can I display a popup to the user that says no delivery #'s found, then after they click on ok, set the focus back on #1 so they can enter another one?

Thanks!

Charlie

Screen Layout
0
Comment
Question by:cafulford
[X]
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
  • 2
  • 2
  • 2
6 Comments
 
LVL 12

Accepted Solution

by:
jrbbldr earned 250 total points
ID: 33683833
I would first save the current value of Grid1's textbox into some Form Property to use to determine if the value has been changed or not.   I would do this in the Grid texbox's WHEN Method.

Something like:
   * --- Capture Value Upon Entry Into Grid1 textbox ---
   SELECT TrackNos    ThisForm.WhenValue = TrackNos.TrackNo   && WhenValue is an added Property of the Form

Then you can write code into the VALID Method for Grid1's textbox to implement the code you need.

Something like:
  mWhenValue = ThisForm.WhenValue   mValue = ThisForm.Value   IF mWhenValue # mValue       * --- Value Has Been Changed ---       < do whatever >      * --- Update Display In Grid2 ---      ThisForm.Grid2.Refresh
     * --- Now Change Record Pointer For Grid1 ---       SELECT TrackNos       LOCATE FOR EMPTY(TrackNos.TrackNo) && Go to next empty Grid1 record       ThisForm.Grid1.Refresh   ELSE      * --- Value Left Alone ---
     < do Whatever >   ENDIF
NOTE - as Pavel (pcelba) pointed out before, I am not testing this code, just offering it as a suggested approach.

Good Luck


0
 

Author Comment

by:cafulford
ID: 33683878
Thanks jrbbldr, thoughts on my question #2?
0
 
LVL 29

Assisted Solution

by:Olaf Doschke
Olaf Doschke earned 250 total points
ID: 33684823
In regard to question #1 - it would be easier to let users simply use the down arrow instead of enter. Enter will step to the next field, as the grid only has one column there is no so you stay in the cell on the same row.

But you could simply put KEYBOARD '{DNARROW}' into the Valid() method of the grid's textbox.

In regard to the popup: If you use SET FILTER as in your other form last week, then after the LOCATE check for EOF() and if that is the case there is no match and you can display a messagebox:

SET FILTER ...
LOCATE
IF EOF()
   Messagebox("No records found for the entered Delivery #, please try again.",0, "Assign Tracking Numbers")
ENDIF

Bye, Olaf.
0
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: 33684837
Even more speaking for itself check IF NOT FOUND() instead of IF EOF().

Bye, Olaf.
0
 
LVL 12

Expert Comment

by:jrbbldr
ID: 33684863
I'll let you determine where in your code you would determine if no Delivery # was found, but wherever that is you could easily add.

Suggestion 1:
    WAIT WINDOW " No Delivery Number Found! " TIMEOUT 2
This 'Alert' window will automatically close after 2 seconds or if the user clicks their mouse.

Or a more lasting approach which will wait for user input.
Suggestion 2:
     cMessageTitle = 'Warning Message'      cMessageText = ' No Delivery Number Found! '      * --- OK Button Only ---      *  0 = OK Button Only
      *  48 = Exclamation mark icon
      *  0 = First button is default
      nDialogType = 0 + 48 + 0
     * --- Yes/No Buttons (not used this time) ---      *  4 = Yes and No buttons
      *  32 = Question mark icon
      *  256 = Second button is default
      *nDialogType = 4 + 32 + 256
     nAnswer = MESSAGEBOX(mcMessageText, nDialogType, mcMessageTitle)

I am not clear on whether you want to return to the Grid1 record or to the Delivery # Textbox

If you want to return to the Grid1 then...
            ThisForm.Grid1.SetFocus
If you want to return to the Delivery # textbox
           ThisForm.txtDeliveryNo.SetFocus

Good Luck

0
 

Author Closing Comment

by:cafulford
ID: 33684882
Thanks again! Much appreciated.
0

Featured Post

Independent Software Vendors: 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!

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…
Article by: Justin
In light of the WannaCry ransomware attack that affected millions of Windows machines, you might wonder if your Mac needs protecting. Yes, it does and here is how to do it.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
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 …

688 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