Solved

Visual Foxpro 6 - focus and grid question

Posted on 2010-09-15
6
1,422 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

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…
What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

867 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

26 Experts available now in Live!

Get 1:1 Help Now