INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How to compare to columns

How to compare to columns

(OP)
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

RE: How to compare to columns

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.


RE: How to compare to columns



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

RE: How to compare to columns

(OP)
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 smile

Thx again all of you!!!!

David

RE: How to compare to columns


Hey, Hey!

Not ALL your questions! smile

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

Anywhay, good luck!

Frank

RE: How to compare to columns

(OP)
Ok,

I will try not to put more than 5 a day winky smile

Thx,

David

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close