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.
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
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
&&...keep first company record
lFirstRec = .F.
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