Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2004
    Posts
    19

    Unanswered: Adding multiple names to a file in foxpro

    I have a database of companies and contacts, 5 records could be the same company but with a different contact, they are currently stored as a seperate record. How can I get it so I can have all the contacts for a company be on 1 record. I would use fields like fname1,lname1, fname2,lname2, fname3,lname3, fname4,lname4
    I know I would have to start by looping through the database somehow.

    I am using Visual Foxpro 7.0
    Any Ideas ?

  2. #2
    Join Date
    Dec 2003
    Posts
    104
    You should post the solution I sent via email in case others are interested.
    DSummZZZ

    Even more Fox stuff at
    www.davesummers.net/foxprolinks.htm

  3. #3
    Join Date
    Apr 2004
    Posts
    19

    Thanks Dave! You are the man!

    Quote Originally Posted by DSummZZZ
    You should post the solution I sent via email in case others are interested.
    1st off, Dave is a great guy! He helped me out and I have used the code he provided to "customize" it to my needs but below is the original code, going to a limit of 5 contacts, this can be changed by making the "nCounter" variable anything you need. Thanks again Dave, this dude is definatly a "guru" and really went out of his way to help me out exchanging multiple emails with me to answer my million questions. Thanks again man! Remember, I have altered this code drasticly to fit my needs but below is Dave's example and it kicks but!

    USE work2 IN 0 ORDER company
    USE work3 IN 0
    SELECT work2

    GO TOP
    STORE ' ' TO cTemp
    STORE .F. TO lFirstRec
    DO WHILE !Eof()
    IF work2.company # cTemp &&... new company
    STORE work2.company TO cTemp
    lFirstRec = .T.

    STORE 1 TO nCounter
    DO WHILE work2.company == cTemp
    IF nCounter > 5
    SKIP
    LOOP
    ENDIF
    SELECT work3

    &&...keep first company record
    IF lFirstRec
    APPEND BLANK
    lFirstRec = .F.
    ENDIF

    STORE 'fname' + Alltrim(Str(nCounter)) TO cFirstName
    STORE 'lname' + Alltrim(Str(nCounter)) TO cLastName

    replace company WITH work2.company

    replace (cFirstName) WITH work2.fname
    replace (cLastName) WITH work2.lname
    *... any other fields like phone, fax, email here

    SELECT work2
    SKIP
    nCounter = nCounter + 1
    ENDDO
    ENDIF
    ENDDO

  4. #4
    Join Date
    Dec 2003
    Posts
    104
    Gee, thanks.
    DSummZZZ

    Even more Fox stuff at
    www.davesummers.net/foxprolinks.htm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •