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

How to compare to columns

Status
Not open for further replies.

RTR1900

Programmer
Mar 12, 2006
8
ES
Hi,

1) I have two tables: ARTI and MLOC
ARTI: Articles (columns: COD_ART, DESCRIPTION,.....)
MLOC: Location of the articles (columns: COD_ART, LOCATION)

2) When I go to a product, I press F8 and I want to show on screen a list of
the locations of that specified article.
So in table MLOC, there are multiple records with the same COD_ART (Code of
article), but different locations.

When I am in the screen of the article I scan the MLOC table and .... [here
is my problem] only want to display the records which have the same COD_ART.

I only get the "first" record of the MLOC table which has that condition.


My code is :

===
Function TEST()

LOCAL nSavRecord := RECNO()
IF ( MLOC->(DBSEEK(arti->COD_ART)) )
@0,0 SAY "YES WE HAVE SOMETHING"
x=1
Do WHILE .NOT. EOF()
IF ( MLOC->(DBSEEK(arti->COD_ART)) )
@1,x SAY mloc->LOCATION
endif
x=x+10
SKIP
ENDDO
ELSE
@0,0 SAY "NOTHING"
END
GOTO nSavRecord

Return .t.

===


Any help is welcome!!!!

P.S.: I just started since yesterday in CLipper

Thx

David
 
David,

Why is the DBSEEK within the DO WHILE loop? The way I do it is to SEEK before the DO WHILE starts and then just test within the loop for the right COD_ART. I also test prior to the start of the DO WHILE to ensure that I found the record I was SEEKING. If not found you can display a message indicating that status. I believe the way you have it wired you will always get the first match every time the DBSEEK is executed. SEEK once and skip record to record to find a match.

Jim C.


 


What Jim means is something like this:

Function TEST()
LOCAL nSavRecord := RECNO()

IF ( MLOC->(DBSEEK(arti->COD_ART)) )
@0,0 SAY "YES WE HAVE SOMETHING"
x=1
// Presuming the fieldname in MLOC table is
// also COD_ART
DO WHILE mloc->COD_ART == arti->COD_ART
@1,x SAY mloc->LOCATION
x=x+10
mloc->(dbskip()) // A better way of skipping!
ENDDO
ELSE
@0,0 SAY "NOTHING"
END
GOTO nSavRecord

Return .t.


Greetings,

Frank
 
Hi frank,

Thx for helping me out!
I am still waiting for a "second hand" book I ordered.

One of my error is that I added some data to the DB using DBF viewer 2000. And I forgot making the Index again....

Anyway I am glad knowing that I can put all my questions here and that there are people there to help me :)

Thx again all of you!!!!

David

 

Hey, Hey!

Not ALL your questions! :)

I'm looking for answers myself most of the time!

Anywhay, good luck!

Frank
 
Ok,

I will try not to put more than 5 a day ;-)

Thx,

David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top