Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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!

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

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...This has been the MOST helpful forum that I have been a part of and I want to say thank you. The tips, tricks and helpful advice that you all contribute to have been lifesavers in many instances..."

Geography

Where in the world do Tek-Tips members come from?
RTR1900 (Programmer)
21 Sep 06 8:55
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
JCreamerII (MIS)
21 Sep 06 10:10
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.


Frandalf (Programmer)
22 Sep 06 2:14


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
RTR1900 (Programmer)
22 Sep 06 7:40
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

Frandalf (Programmer)
23 Sep 06 12:31

Hey, Hey!

Not ALL your questions! smile

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

Anywhay, good luck!

Frank
RTR1900 (Programmer)
25 Sep 06 3:41
Ok,

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

Thx,

David

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!

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