Error 5 record out of range strangeness
Error 5 record out of range strangeness
(OP)
Usually this error is simple, you tried to go where a record does not exist, however this one is strange and is happening repeatedly on two computers out of 60 that run it. The rest of the people who use it have not seen the error which makes this all the more interesting, but could simply be that they use it in a slightly different way, now to the facts.
The application runs locally and it not a shared or network application. It is a form with a 6 tab page frame. The error 5 when trapped is telling me that on page frame 1 a list object with an SQL statement as it's row source is what's causing the problem. What is interesting is that when the error occurs it's happening while the user is interacting with objects on page frame 2 which programmatically does not touch page frame 1 or any of it's objects nor does it cause any type of requery. As a test I disabled everything on page frame 1 while they are on page frame 2 using .setall so every object was disabled, still the error persisted.
Example error messages
Error number : 5
Program : OE.FRAME.ORDERGUIDE.OITEMSEARCH.LOSTFOCUS
Line number : 32
Line of code : select invoice_date,lines,quantity,sales from saleshistory where customer_id=customer.customer_id order by invoice_date desc into cursor saleshist
Error message: Record is out of range.
Error number : 5
Program : OE.FRAME.ORDERGUIDE.OITEMSEARCH.GOTFOCUS
Line number : 11
Line of code : select invoice_date,lines,quantity,sales from saleshistory where customer_id=customer.customer_id order by invoice_date desc into cursor saleshist
Error message: Record is out of range.
Error number : 5
Program : OE.EXISTINGORDER
Line number : 173
Line of code : select invoice_date,lines,quantity,sales from saleshistory where customer_id=customer.customer_id order by invoice_date desc into cursor saleshist
Error message: Record is out of range.
oe.existingorder is a method on the base form that I call when they edit an order, the other two got and lost focus are on page frame 2 of a search text box. Again these objects/methods do not touch or refresh anything on page frame 1 where the list is with the SQL statement. It is one of those strange things that started out of nowhere and in happening on 2 of the 60 people who use it. We cannot duplicate the problem ourselves using the application, usually we can.
Now to make things more complex this message happens on occaision
Error number : 202
Program : OE.FRAME.ORDERGUIDE.DONE.CLICK
Line number : 99
Line of code : select invoice_date,lines,quantity,sales from saleshistory where customer_id=customer.customer_id order by invoice_date desc into cursor saleshist
Error message: Invalid path or file name.
BTW just to be clear on all of the errors above the "Line of Code" is the list box with a row source SQL statement that you see and is located on
OE.FRAME.CUSTOMER.SALESHISTORY <- Saleshistory being the list box object.
The error is related to the same object on page frame 1, the list with a SQL statement as the row source, yet there is nothing related to a path or file name,the statement returns results to a named cursor not a dbf file with a path. Very confusing and I'm beginning to think some other application on the local machines are causing it in some odd way. This is Windows 11 and Fox 9 with SP2 and the group header hot fix installed from article 968409
Thanks, this has been going on for a week and I've been through some strange issues with Fox over the years but this one finally has me asking for help here.
The application runs locally and it not a shared or network application. It is a form with a 6 tab page frame. The error 5 when trapped is telling me that on page frame 1 a list object with an SQL statement as it's row source is what's causing the problem. What is interesting is that when the error occurs it's happening while the user is interacting with objects on page frame 2 which programmatically does not touch page frame 1 or any of it's objects nor does it cause any type of requery. As a test I disabled everything on page frame 1 while they are on page frame 2 using .setall so every object was disabled, still the error persisted.
Example error messages
Error number : 5
Program : OE.FRAME.ORDERGUIDE.OITEMSEARCH.LOSTFOCUS
Line number : 32
Line of code : select invoice_date,lines,quantity,sales from saleshistory where customer_id=customer.customer_id order by invoice_date desc into cursor saleshist
Error message: Record is out of range.
Error number : 5
Program : OE.FRAME.ORDERGUIDE.OITEMSEARCH.GOTFOCUS
Line number : 11
Line of code : select invoice_date,lines,quantity,sales from saleshistory where customer_id=customer.customer_id order by invoice_date desc into cursor saleshist
Error message: Record is out of range.
Error number : 5
Program : OE.EXISTINGORDER
Line number : 173
Line of code : select invoice_date,lines,quantity,sales from saleshistory where customer_id=customer.customer_id order by invoice_date desc into cursor saleshist
Error message: Record is out of range.
oe.existingorder is a method on the base form that I call when they edit an order, the other two got and lost focus are on page frame 2 of a search text box. Again these objects/methods do not touch or refresh anything on page frame 1 where the list is with the SQL statement. It is one of those strange things that started out of nowhere and in happening on 2 of the 60 people who use it. We cannot duplicate the problem ourselves using the application, usually we can.
Now to make things more complex this message happens on occaision
Error number : 202
Program : OE.FRAME.ORDERGUIDE.DONE.CLICK
Line number : 99
Line of code : select invoice_date,lines,quantity,sales from saleshistory where customer_id=customer.customer_id order by invoice_date desc into cursor saleshist
Error message: Invalid path or file name.
BTW just to be clear on all of the errors above the "Line of Code" is the list box with a row source SQL statement that you see and is located on
OE.FRAME.CUSTOMER.SALESHISTORY <- Saleshistory being the list box object.
The error is related to the same object on page frame 1, the list with a SQL statement as the row source, yet there is nothing related to a path or file name,the statement returns results to a named cursor not a dbf file with a path. Very confusing and I'm beginning to think some other application on the local machines are causing it in some odd way. This is Windows 11 and Fox 9 with SP2 and the group header hot fix installed from article 968409
Thanks, this has been going on for a week and I've been through some strange issues with Fox over the years but this one finally has me asking for help here.
RE: Error 5 record out of range strangeness
REINDEX might help, but the question is why the data gets out of sync and that could be an SMB protocol issue.
Chriss
RE: Error 5 record out of range strangeness
However I'm wondering if it is a local DBF/Index issue and the line of code returned by the error is not related at all, hrmmm?
RE: Error 5 record out of range strangeness
Chriss
RE: Error 5 record out of range strangeness
thanks for all the replies.
RE: Error 5 record out of range strangeness
Chriss
RE: Error 5 record out of range strangeness
I think your original comment about the index of the source table selecting from sounds like the problem. We shall see what happens this week. It is still strange that users interacting with objects on another frame that programmatically do not touch or refresh objects on the other frame are causing this to happen.
RE: Error 5 record out of range strangeness
I never use a query as a rowsource, so one of the things you can also do is put that query into init of the listbox and set the rowsourcetype to alias or fields instead.
Chriss
RE: Error 5 record out of range strangeness
I found out that using the application as a stand alone .EXE the error routine is reporting the WRONG line of code. If I run the application in FoxPro development and force a record out of range by running "go 50000" where there is only 3900 records the error routine give the correct line of code "go 50000" however when I run it as an executable it give me a line of code that has nothing to do with the offending code.
Is there a way to fix this or a trick you need for .exe to report the correct line of code? Until them I'm going to have some people run the application in VFP and not an EXE to find out what is going on.
RE: Error 5 record out of range strangeness
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
Visual FoxPro articles, tips and downloads
RE: Error 5 record out of range strangeness
RE: Error 5 record out of range strangeness
Besides that, Mike is right about the debug info being important to get correct line numbers of error handling with the LINENO() parameter or within AERROR or ASTACKINFO.
If the source is - as I suspect a QL query the line of code should be it, but you'll not find out the offending index entry or record number. The only other non code source of the problem could be by a RELATION automatically navigating by index to a non existing record number.
The problem could also be as easy as a GO RECNO, notice in buffered mode new records get negative RECNO() and that only changes when they have been stored to the DBF in a final position. So GOing to a record number within 1 to RECCOUNT() could not work for numbers near the end of the buffered workrea.
Chriss
RE: Error 5 record out of range strangeness
set coverage did not work, it shows the form being created line by line, inits, frames etc but not when I click the button I created that does "go 50000".
The error message while in FoxPro development is correct and reports
Error number : 5
Program : OE.COMMAND1.CLICK
Line number : 1
Line of code : go 50000 in order_temp
Error message: Record is out of range.
Run this as an EXE and you get
Error number : 5
Program : OE.COMMAND1.CLICK
Line number : 1
Line of code : select Created,cdow(order_date), order_date, left(po,14) po,totalquantity,totalamount,reserved,IIF(review=.t.,'Review',' ') review,spins,order_id from orders where customer.customer_id=orders.customer_id order by order_date into cursor customerorders
Error message: Record is out of range.
As you can see the line of code is incorrect - strange behavior as the other information is correct.
RE: Error 5 record out of range strangeness
Instead of
you may want to try
CODE -->
hth
MarK
RE: Error 5 record out of range strangeness
This - very briefly said - embeds all source code, too.
Chriss
RE: Error 5 record out of range strangeness
I replied that Debug info is checked.
mjcmkrsr:
Read more of the thread, that is not the actual line of code that is the error. For some reason the .EXE is returning different results then when in development and it's driving me a little crazy. Also that select SQL statement has been there for over a decade.
We are going to have someone run the application in FoxPro (not the EXE) and get the real error. I can't wait to see what this is.
Thanks for all the replies.
RE: Error 5 record out of range strangeness
...
You forgot to list the second table in all the SQL statements and hopefully the field names are unique - otherwise you would have to precede the field name(s) with the table name(s)
I suggest the following
CODE -->
or to avoid confusion
CODE -->
hth
MarK
RE: Error 5 record out of range strangeness
RE: Error 5 record out of range strangeness
Well, as the first line of your Click method triggers ON ERROR this will be in the coverage log file.
What was the end of the coverage log file? Did you set coverage off somewhere? Btw, You could make it a lot shorter, if you put it at the end of form init.
Chriss
RE: Error 5 record out of range strangeness
Thanks will update when I know more later this afternoon.
RE: Error 5 record out of range strangeness
RE: Error 5 record out of range strangeness
The easiest way is to set a breakpoint. You do this by double-clicking in the left-hand margin of the code window, or by right-clicking and selecting "Toggle breakpoint". Either way, do this at the line of code at which you want to start debugging.
Although you can (and should) remove the breakpoint when you have finished debugging, no harm is done if you don't do that. Breakpoints only exist in the development environment, and are not carried through to the executable.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
Visual FoxPro articles, tips and downloads
RE: Error 5 record out of range strangeness
RE: Error 5 record out of range strangeness
- any FoxUser file?
- any Config.FPW?
- registry settings?
- paths?
- ...
Tamar
RE: Error 5 record out of range strangeness
I looked at all the open tables to see if any of them were at EOF(), one was that should not be that is tied to a COMBOBOX. I think I have narrowed it down to a "LIST" and a "COMBOBOX" that are local tables that get wiped (zapped) and reloaded when a new order is created or an existing order is edited. I think the combo or list is pointing to a record that becomes unavailable when the underlying table is reloaded and a refresh is issued. Why this started happening now versus years of trouble free run time is strange however I think issuing a requery on these objects before a refresh might be what's needed to rebuild the list/combo listindex. I'm also going to convert the list to a grid, as I have no issus reloading the underlying table with grids and then a form refresh or grid refresh.
RE: Error 5 record out of range strangeness
I made the experience this makes listbox and combobox more stable and less sensitive to lost rowsource. The grid is infamous to break, if the recordsource vanishes, even just for split seconds if you do a query INTO grid.recordsource and overwrite the existing grid cursor with new data. The grid is not sensitive if such a requery is done on a view, as the view workarea stays in place during the whole requery process (and here I'm talking about the REQUERY() function for views, the grid control has no requery method, as it works differently in that respect.
I can't answer why this didn't show up for years, but it's not the first time something works long lasting and finally breaks for some unknown reason.
I do remember commbo nd list breaking mostly when you change active forms. When something is askew while a form is reactivated it breaks. A form.refresh is quite similar to such a situation and I often see people putting way to much code into the refresh event, which they don't realize causes further refresh events in what is a cascading method anyway. I learned the hard w ost often a setfocus is the better alternative to a control.refresh, if it comes to a single control. If you want to refresh a form, the form.refresh() is a natural way, but you need to realize you're shaking up everything on the form. The less code you have in refresh, the less side effects. So that's a warning of what you say you plan to do.
I would take a "snapshot" of what happens with event tracking and coverage logging could also help. You might detect loopbacks where you don't expect them to happen.
But in detail you might be very right about the suspicion that a requery before a refresh would be good, as I think a refresh does cause many things but does not cause a requery in itself.
Chriss
RE: Error 5 record out of range strangeness
To keep things simple do you think a .requery in the refresh method of lists and combos would cure this?
RE: Error 5 record out of range strangeness
Zapping a cursor is never disturbing a grid, it might so for combo/list because of the items, so changing to a grid also could already "heal" it.
Chriss
RE: Error 5 record out of range strangeness