Solved

Visual Foxpro 6 - focus and grid question

Posted on 2010-09-15
6
1,394 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

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…
HOW TO: Install and Configure VMware vSphere Hypervisor 6.5 (ESXi 6.5), Step by Step Tutorial with screenshots. From Download, Checking Media, to Completed Installation.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 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

18 Experts available now in Live!

Get 1:1 Help Now