Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Ken Murphy
  Where is Ken Murphy?
 Springhill
 Canada
 Ken Murphy
 Tags
Subject: Strange error
Thread ID: 104017 Message ID: 104017 # Views: 1 # Ratings: 1
Version: Visual FoxPro 9 Category: Errors & Debugging
Date: Thursday, August 10, 2006 8:18:29 PM         
   


Here is one that I have never run into before. I have an app called Child Maintenance where we enter the data on children from the developing world that we sponsor (we are a child sponsorship organization similar to World Vision except we are Catholic.)

The app is a basic file maintenance form. On the left hand side of the form, I have a drop down list that allows the user to select a search criteria. Directly underneath, I have a searchtext textbox and directly underneath that, I have a listbox where I present a candidate list. The user selects the type of search to perform from the dropdown and then enters the text to search for in the textbox. In the .Valid of the textbox, I initiate the search using a DO CASE construct - one case for each search type. If the search is successful, the app displays the matching children in the listbox. The search procedure automatically selects the last item in the list and issues a ThisForm.ChildList.Click() In the .Click, I call a custom form method that displays that child's information. In this method, the app SEEK()s the child's project and sub-project in the project.dbf and subproject.dbf tables (don't blame me for the use of a reserved word as a table name - I inherited it.) If either of these SEEK()s fail, an error message is displayed.

One of the search types that I have is "ChildID." This searches for the childID assigned at the project (not the child record ID field.) The child ID has an input mask of [!!!9999999] and there is an index on the ChildID field. When I populate the candidate list, I use a SEEK()/SCAN WHILE construct. A user enters "ABC" and the app will find all of the chidren where the child ID starts with "ABC" - so far all works well. The users are now entering child records with a child ID starting with YPK. If the ChildID index is set, YPK1041 is the last child record. When I enter YPK into the search text box, the candidate list fills appropriately, it automatically .Click()s and the child information is displayed but at this point, and only on this record, the app tells me that it cannot SEEK() that child's project or sub-project. If I then click child YPK1040 the app works perfectly. If I again, click child YPK1041, the SEEK()s on project and sub-project work perfectly. If I go back up to the searchtext and enter YPK again, the SEEK()s fail again.

My first thought was "there has to be a data problem." I compaired YPK1040 to YPK1041 and found that the project and subproject ID's were identical in both child records. I add a new child record, YPK1042. Now YPK1041 works perfectly and YPK1042 has the error.

Worse still, this code has not changed in 18 months and this error just showed up this week. I KNOW this code works. As any body else run into problems with "the last logical record for that index?"

The appropriate code is as follows:
*** SearchText.Click()
lnRetVal = 0
This.parent.ChildList.Clear 
n = 0
IF !EMPTY(ALLTRIM(This.Value))
	DO Case
	CASE This.parent.SearchType.Value = 1	&& Child ID
		SELECT Child
		SET ORDER TO TAG ChildID
		IF SEEK(UPPER(ALLTRIM(This.Value)))
			SCAN WHILE ChildID = UPPER(ALLTRIM(This.Value)) 
				n = n + 1
				lcName = ALLTRIM(Child.firstname-(" "+ ;
								 Child.middle)-(" "+ ;
								 Child.family))
				This.parent.ChildList.AddItem(Child.ChildID,n,1)
				This.Parent.ChildList.List(n,2) = lcName 
				This.Parent.ChildList.ItemData(n) = Child.childno
			ENDSCAN 
			IF This.Parent.ChildList.ListCount > 0
				ThisForm.DisplayChild
				This.Parent.ChildList.Selected(This.Parent.ChildList.ListCount) = .t.
				This.Parent.ChildList.Click 
				lnRetVal = 1
			ELSE
				MESSAGEBOX("Could not find a child with this ID.",16,"Search Failed")
				lnRetVal = -1
			ENDIF 
		ELSE
			MESSAGEBOX("Could not find this child ID",16,"Search Failed")
			lnRetVal = -1
		ENDIF 
	CASE...
ENDCASE

*** ChildList.Click()
SELECT child
SET ORDER TO TAG ChildNo
FOR i = 1 TO This.ListCount
	IF This.Selected(i)
		lnChildNo = This.ItemData(i)
		IF SEEK(lnChildNo)
			ThisForm.DisplayChild
		ELSE
			MESSAGEBOX("Could not seek this child",16,"Technical Error")
			...
		ENDIF
	ENDIF
ENDFOR

*** ThisForm.DisplayChild()
SELECT Project
SET ORDER TO TAG ProjectNo
IF SEEK(Child.ProjectNo)
	lcProject = Project.projectid
ELSE
	MESSAGEBOX("Could not seek project",16,"Technical Error")
	lcProject = ""
ENDIF
SELECT SubProject
SET ORDER TO TAG SubNo
IF SEEK(Child.subno)
	lcSubProject = Subproject.subproject
ELSE
	MESSAGEBOX("Could not seek sub-project",16,"Technical Error")
	lcSubProject = ""
ENDIF


Any ideas - I am stumped.

Ken
You shall know the truth - and the truth shall set you free. (John 8:33)

ENTIRE THREAD

Strange error Posted by Ken Murphy @ 8/10/2006 8:18:29 PM
RE: Strange error Posted by Pete Sass @ 8/10/2006 9:37:39 PM
RE: Strange error Posted by Ken Murphy @ 8/10/2006 10:32:45 PM
RE: Strange error Posted by Joselito Watiwat @ 8/14/2006 7:32:51 AM
RE: Strange error Posted by Sergey Karimov @ 8/10/2006 9:38:33 PM
RE: Strange error Posted by Ken Murphy @ 8/10/2006 10:44:39 PM
RE: Strange error Posted by Sergey Karimov @ 8/10/2006 11:25:40 PM
RE: Strange error Posted by Ken Murphy @ 8/11/2006 1:33:41 AM
RE: Strange error Posted by Andy Kramek @ 8/10/2006 11:15:31 PM
RE: Strange error Posted by Ken Murphy @ 8/11/2006 1:47:56 AM
RE: Strange error Posted by Andy Kramek @ 8/11/2006 11:34:21 AM
RE: Strange error Posted by Ken Murphy @ 8/11/2006 12:02:50 PM
RE: Strange error Posted by Pete Sass @ 8/16/2006 10:21:42 PM
RE: Strange error Posted by Ken Murphy @ 8/17/2006 1:53:54 AM
RE: Strange error Posted by Ken Murphy @ 8/21/2006 7:06:31 PM
RE: Strange error Posted by David Hall @ 8/23/2006 12:06:06 PM
RE: Strange error Posted by Ken Murphy @ 8/23/2006 2:45:16 PM
RE: Strange error Posted by David Hall @ 8/31/2006 5:38:45 PM
RE: Strange error Posted by Ken Murphy @ 8/31/2006 6:17:39 PM
RE: Strange error Posted by Jim Winter @ 8/31/2006 6:44:57 PM
RE: Strange error Posted by tushar @ 8/31/2006 7:06:07 PM
RE: Strange error Posted by Ken Murphy @ 8/31/2006 7:41:37 PM
RE: Strange error Posted by tushar @ 8/31/2006 7:46:59 PM
RE: Strange error Posted by Ken Murphy @ 8/31/2006 8:11:52 PM
RE: Strange error Posted by tushar @ 8/31/2006 9:05:03 PM
RE: Strange error Posted by Jim Winter @ 8/23/2006 3:30:45 PM
RE: Strange error Posted by David Hall @ 9/11/2006 4:19:02 PM
RE: Strange error Posted by Ken Murphy @ 9/11/2006 4:35:59 PM
RE: Strange error Posted by David Hall @ 9/12/2006 11:10:28 AM