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

cdx order is changing on its own?

Status
Not open for further replies.

butchkmd

Programmer
Nov 13, 2001
83
US
I have an exe I created, which continuously gets errors from my searches not working properly. When I look at the table I find the order the indexes I'm using are changing for no apparent reason.
Ex. I enter the index in this order
1 Lastname
2 Firstname
3 id number

When I go back after the error they will be listed as follows

1 idnumber
2 Lastname
3 Firstname

what makes them shift and how do I stop it?

Thanks
 
*!* this sorts main table by lastname, cLastSearch is
*!* value from textbox on search form


LPARAMETERS cLastSearch

SELECT 0
USE ALLTRIM(cfilepath) + 'prsimmig'
SET ORDER TO 4 && filter db by lastname
GOTO TOP
SET EXACT OFF
SEEK cLastSearch
IF FOUND()
SELECT 0
USE ALLTRIM(cfilepath) + 'ReportTable'
ZAP
DO WHILE cLastSearch = SUBSTR(prsimmig.lastname,1,LEN(cLastSearch))
SELECT ReportTable
APPEND BLANK
REPLACE ReportTable.lastname WITH prsimmig.lastname && transfers data to
REPLACE ReportTable.firstname WITH prsimmig.firstname && temptable
REPLACE ReportTable.id_num WITH prsimmig.A_Number
REPLACE ReportTable.date_in WITH prsimmig.date_in
REPLACE ReportTable.amount WITH prsimmig.amount
REPLACE ReportTable.rec_num WITH prsimmig.rec_num
IF EMPTY(prsimmig.out)
daysin = (DATE() - prsimmig.date_in)
REPLACE ReportTable.days_In WITH daysin
REPLACE ReportTable.monthlybal WITH daysin * 60
ELSE
REPLACE ReportTable.out WITH prsimmig.out
daysin = prsimmig.out - prsimmig.date_in
REPLACE ReportTable.days_In WITH daysin
REPLACE ReportTable.monthlybal WITH daysin * 60
ENDIF
SELECT prsimmig
IF EOF()
MESSAGEBOX ('Entry not found'+(CHR(13))+'...please retry',32,'Record Search Incomplete')
EXIT
ELSE
SKIP 1
ENDIF
ENDDO
DO tableformat && temptable stores data formated from reporttable
ENDIF
release cLastSearch

this may seem strange and it's a long story (all the tables and sorting) but the seek it's self is what you need to see I assume.
 
*!* this sorts main table by lastname, cLastSearch is
*!* value from textbox on search form


LPARAMETERS cLastSearch

SELECT 0
USE ALLTRIM(cfilepath) + 'prsimmig'
SET ORDER TO 4 && filter db by lastname
GOTO TOP
SET EXACT OFF
SEEK cLastSearch
IF FOUND()
SELECT 0
USE ALLTRIM(cfilepath) + 'ReportTable'
ZAP
DO WHILE cLastSearch = SUBSTR(prsimmig.lastname,1,LEN(cLastSearch))
SELECT ReportTable
APPEND BLANK
REPLACE ReportTable.lastname WITH prsimmig.lastname && transfers data to
REPLACE ReportTable.firstname WITH prsimmig.firstname && temptable
REPLACE ReportTable.id_num WITH prsimmig.A_Number
REPLACE ReportTable.date_in WITH prsimmig.date_in
REPLACE ReportTable.amount WITH prsimmig.amount
REPLACE ReportTable.rec_num WITH prsimmig.rec_num
IF EMPTY(prsimmig.out)
daysin = (DATE() - prsimmig.date_in)
REPLACE ReportTable.days_In WITH daysin
REPLACE ReportTable.monthlybal WITH daysin * 60
ELSE
REPLACE ReportTable.out WITH prsimmig.out
daysin = prsimmig.out - prsimmig.date_in
REPLACE ReportTable.days_In WITH daysin
REPLACE ReportTable.monthlybal WITH daysin * 60
ENDIF
SELECT prsimmig
IF EOF()
MESSAGEBOX ('Entry not found'+(CHR(13))+'...please retry',32,'Record Search Incomplete')
EXIT
ELSE
SKIP 1
ENDIF
ENDDO
DO tableformat && temptable stores data formated from reporttable
ENDIF
release cLastSearch

this may seem strange and it's a long story (all the tables and sorting) but the seek it's self is what you need to see I assume.

Thanks
 
Sorry to make you do another copy-and-paste, but I'd like to see the code that actually creates the indices.
The SET ORDER TO 4 line scares the heck out of me. What if another routine updates indices by trashing the old ones and recreating them? If you have ONE routine that does that, you're fine. Personally, I never use code like SELECT 4 or SET ORDER TO 4. I always use the actual alias name or tag name. ** Gerry White
** (soon)
** Are we having fun yet?
 
HI
1. Cleanup your project. For this.. With the project window in focus.. click on project menu of the VFP MainMenu and click on cleanup project
2. REbuild the project with all component Ids selected.

If the problem exits.. you are obviously doing the order change somewhere. Probable place.. you might be using a grid class where .. clicking the header could change the grids order.. meaning.. the table gets into a different order.

Hope this helps you :)
ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
I will be glad to rebuild it if need be. Let me throw another bit out there. The users and I have been working on cleaning up the tables ie: double entries and misspellings and stuff. After marking files for deletion I pack and reindex the table. Does this change the order of how they are listed? This morning I did just that, it seems if I touch the tables the order changes.
could be???? As for the code establishing the index file I typed it right into the table properties dialoge box on the index tab.

I appreciate the help I'm pretty new to programming if you haven't guessed

Thanks


 
If I undrestand the responce above I should be able to simply use the tag name and it will do the same thing? That sounds a lot better to me.
 
I changed the code in my copy of the program and it tested fine using the tag names. Thank you very much I hope this takes care of it. I appreciate it.
 
Yes, I was hoping that using real names, instead of numbers, for setting things up is a lot more reliable --- and readable.
Enjoy! Glad to help.
- Gerry ** Gerry White
** (soon)
** Are we having fun yet?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top