Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Edit with no records to show

Status
Not open for further replies.

Drainie

Programmer
Jul 31, 2002
16
GB
I’m using the FoxPro 2.6 EDIT command (similar to BROWSE) to show a number of records in a window:

SELECT "qulines"
SET ORDER TO qutime
EDIT FIELDS ;
client_1 = qutime + "|" + quref_x:70:H="":W=p_exclude(), ;
client_2 = qutype + SPACE(1) + qucon + "|" ;
+ qupet_x + "|" + qursn_x:70:H="":W=p_exclude() ;
FOR p_quseq = quseq ;
NOAPPEND ;
NODELETE ;
NOMENU ;
TITLE " " ;
WINDOW qumast ;
COLOR SCHEME 10

which limits the records shown by comparison of a memory variable (p_quseq) and a field in the table (quseq).

I also make use of:

ON KEY LABEL RIGHTARROW DO p_change WITH "+"
ON KEY LABEL LEFTARROW DO p_change WITH "+"
ON KEY LABEL HOMEARROW DO p_change WITH "="

which links to:

PROCEDURE p_change
PARAMETER w_quparm
IF w_quparm = "+"
p_quseq = p_quseq + 1
ENDIF
IF w_quparm = "-"
p_quseq = p_quseq - 1
ENDIF
IF w_quparm = "="
p_quseq = DATE()
ENDIF
SELECT "qulines"
LOCATE FOR quseq = p_quseq
RETURN

Moving around (backwards, forwards, returning to today) works UNTIL I hit a day with no records to show.

When that happens, I get a blank list – which I expect.

What I didn’t expect is that if I move to a list that should have records to display, I still get a blank list.

For example, when I start, suppose I have 6 records to show for the initial value of p_quseq and move forwards by one day using the right-arrow key to a day with NO records to show, I get a blank list - expected. If I then move back to the previous day, I still see no records – although I know there a six matching records in the table.

My question is how do I overcome this?

 
if you pasted this code from your original prg file then

on error

1. ON KEY LABEL RIGHTARROW DO p_change WITH "+"

2.ON KEY LABEL LEFTARROW DO p_change WITH "+"

3. ON KEY LABEL HOMEARROW DO p_change WITH "="

I think it is your typo. You have put "+" instead of "-" in line 2 above.

 
Thank you for pointing out my typing mistake.

The original code does, indeed, use "-" for LEFTARROW parameter. I simply mis-typed the line when I made the original posting.

So, I'm afraid, I still have the problem.
 
Is it possible that you are encountering a conflict between your use of the ARROW keys and EDIT's standard usage behavior of the ARROW keys?

Why not try using available function keys (F1-F12, though be aware some of these keys too may be used by FoxPro defaults such as F1 for Help) instead for your custom selection keys and see if that resolves your issue?
 
Thanks for taking the time to read the post and for your suggestion.

Have just tried replacing ARROW keys with F3 and F4 but still have the same problem.

Tried then ON KEY LABEL "F" and ON KEY LABEL "B", but to no avail.

Thanks anyway.
 
Then perhaps could this be an issue where you ought to exit the EDIT command and re-enter the EDIT command? What you are doing is putting the filter on the entry to the EDIT level. Perhaps it would be best to use SET FILTER TO <condition> and GO TOP rather than change the condition variables on the fly? I'm just trying to think how to get around your problem...
 
I've tried the SET FILTER TO option, to no avail. Looks like I'll have to do what you suggest, exit the EDIT command and re-enter again - although that might slow down the application.

As usual, many thanks for your suggestions.
 
I tried your code, the problem arises when ir reaches eof() or bof(), that is no record in focus. At this point, close all the for conditions, save your variables and restart the program. Try something like "return to master". Master(main) program is where you load all the vars and reset the file pointer and call your program.


 
Thanks for your suggestions. Should have twigged EOF() might have been a cause. Restarting program not really an option. Think I've got a work around by making sure EVERY date has at least one (dummy) entry in the table.
 
I think you have to break the "edit ... for " condition and reenter with the new parameters.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top