Solved

Visual Foxpro 6 - focus and grid question

Posted on 2010-09-15
6
1,436 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
  • 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
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: 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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
filtering a list vfp 4 164
Close table 1 214
Best practices regarding backing up maintenance programming 20 130
Import XML file with Base64 image element 3 169
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…
SEO can be a real minefield to navigate, but there are three simple ways to up your SEO game just be re-assessing your content output.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

785 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