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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fox crash after setFocus

Status
Not open for further replies.

tsh73

Programmer
Apr 27, 2002
304
RU
Here's my problem.
(working on a FoxPro 5)
I have a search routine which asks for search string, creates cursor, re-sets it as RowSource for the list.

.ListDocs.RowSource = m.sCursorName+"->NUM_SCH,DATE_SCH,Full_Sum,NDS,spTypeKorr,DATE_BUCH, OLD_SCH, OLD_DATA"

I saw cursor created if I insert "browse" or "save to c:\ttt"
I even saw this item in the list
BUT.
If I execute .ListDocs.setFocus
or just make that window selected - application crash with some uncomprehensible errors
(like
variable OLD_SCH is not found
)
and I just saw that field exist all right.

Actually it occured that it crashes just if I select that line in the list then swich active windows.

Most of the time things work just fine.

So I dumbfolded. What could be the case?
 
.ListDocs.RowSource = m.sCursorName+"->NUM_SCH,DATE_SCH,Full_Sum,NDS,spTypeKorr,DATE_BUCH, OLD_SCH, OLD_DATA"

I've not tried using this sort of shorthand structure before. I would have repeated the cursor name before each field:
Code:
.ListDocs.RowSource = m.sCursorName+"->NUM_SCH, ;
m.sCursorName+"->DATE_SCH, ;
m.sCursorName+"->Full_Sum" ;
etc

What happens if you quote the entire row-source explicitly rather than building the string in code?

Geoff Franklin
 
alvechurchdata,
thanks for reply.

From the help:
------------------
To specify an alias for the table containing the columns, use the following syntax:

Alias.Col1Row1,Col2Row1,Col1Row2,Col2Row2,,Col2Row3
------------------
as happened "->" works too.
Citing alias several times doesn't worked for me.
Any other ideas?
 

Geoff,

I've not tried using this sort of shorthand structure before. I would have repeated the cursor name before each field:

Tsh73 is right. If you had repeated the alias name, you would have got a "Field phrase not found" error (not sure if that's the exact wording, but something like that).




__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 

Tsh73,

Try running it again, but this time, make a note of the exact error message.

If the error mentions a particular field, try removing that field from your Rowsource, and see if that makes a difference.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Also, try using the "dot" notation instead of the "pointing to" notation:
Code:
.ListDocs.RowSource = m.sCursorName+"[b][red].[/red][/b]NUM_SCH,DATE_SCH,Full_Sum,NDS,spTypeKorr,DATE_BUCH, OLD_SCH, OLD_DATA"
and do a requery() after resetting the rowsource if you are not already doing that.


Mike Krausnick
Dublin, California
 
I'm still at that.
Exact error message:
Code:
Alias "" is not found
points to the line with
Code:
ThisForm.ListOutTTN.SetFocus().
(sometimes it just crashes without error message)
or with
Code:
" is not an object."

I wonder how come "" to be alias name |object name, though.

Requery is called.

Tried to create copy of a cursor for recordsource
(sele * from old_cursor_name where .t. into new_cursor_name) and using it - same crash
Tried to remove all fields but first one from recordsource
- same crash

Tried to set event tracking on to see what events fire then I swch between windows but somehow it just plait don't work. What I did wrong? The code was
Code:
SET EVENTLIST TO activate, afterrowcolchange, beforerowcolchange, click, dblClick, deactivate, delete ADDITIVE
SET EVENTLIST TO deleted, destroy, error, errorMessage, gotFocus, Init, InteractiveChange, KeyPress ADDITIVE
SET EVENTLIST TO Load, LostFocus, Message, ProgrammaticChange, Resize, Scrolled, Timer, Unload, QueryUnload ADDITIVE
SET EVENTLIST TO Valid, When ADDITIVE
SET EVENTTRACKING TO c:\ev05.txt
SET EVENTTRACKING ON
and I tried to set it off and close file after with
Code:
SET EVENTTRACKING OFF
SET EVENTTRACKING to

It just skipped my code, no warnings etc, no file created.
(Or is it not supposed to work in compiled EXE?)

I wonder if this is frequent for the fox to crash like that, I got it first time... I had similar problems in Delphi long ago and it was about non-allocated (or released before) string set for form caption.

What could possibly kill FoxPro like that?
 

Well, the obvious possibilities are:

- The alias that you used to populate the listbox is no longer available (you can check that by suspending when the error occurs, then going to the DataSession window).

- There's come code in the listbox's GotFocus or When that is causing the error.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
sorry Mike
I tried to save cursor so it's sure exists
(and it shows in Browse just before line that causing error)

And it have no GotFocus or When events.

Searching for "protection fault" here I found suggestion to re-create index from scratch... So I did, same bad result.

so could I use EVENTTRACKING to see what events exactly firing?
Would it work in compiled EXE?
If it would could someone prvide an example how to use it (or correct code I posted above).

 

Personally, I wouldn't waste time with Event Tracking, especially if you are not completely familiar with it. I don't think it will lead you to the solution.

I'd suggest you try to isolate the problem by creating a new form, intitially without any code or controls. Then add the list box, then gradually add the code and other controls, testing it each time. Either you'll end up with a working form, or you will see exactly where the problem is being introduced.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Ok, I found the reason.
Now I wish I knew how to step it over.
Steps to recreate problem:
- create a database >253 records. I created table with 300 numbers from 1 to 300.
- create a form
- put listbox on a form
- set rowsource to your table, rowsourcetype to Fields. (or Alias)
Run the form.
Now try to select different records and swich back|forth to command window.
It happens that you CANT return to record 253!!!!!
others work just fine.

Saying that, is that known problem|is where may be fix for that?
 

Yes, I remember that bug. It's been such a long time since I saw it, it didn't occur to me that it applied in this case.

In any case, I'd advise against having such a large number of items in a listbox, if only from the point of view of user convenience.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top