[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Visual Foxpro 6 - focus and grid question

Posted on 2010-09-15
6
Medium Priority
?
1,565 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 1000 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 30

Assisted Solution

by:Olaf Doschke
Olaf Doschke earned 1000 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 30

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

872 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