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

Viewing all data from related tables.

Status
Not open for further replies.

Snaggs

Programmer
Jan 11, 2000
393
US
Greetings FoxPro Experts,

I'm a programmer by trade, but not a FoxPro programmer. I inherited a project that's writen in Visual FoxPro 5.0 and have a section that doesn't work.

The following code relates a breeding table to a view based on an index. What I want to do is see the output of what this relationship looks like. Is there a way I can browse or export all the fields and data from both tables through the join so I can see what FoxPro is doing with the records?

select breeding
set order to litterid
select v_birthdates
set relation to litfarm+litgroup+litnumber into breeding

I'm sure this seems like a simple task, but not knowing the language and what's available I don't have a clue how to do this.

One other thing, there is a SCAN/ENDSCAN right after the above code where it replaces a field with a different field. Is there a way for me to print out fields to the immediate window or to a file to see what it's doing in the SCAN loop?

Thanks in advance!
Snaggs
tribesaddict@swbell.net
Life can only be understood backwards; but it must be lived forwards.
 
One key in VFP and setting relations is the field lengths in the 2 tables MUST be the same TYPE and LENGTH.

Check to make sure noone has done something rash like change a field on you.

inside the scan loop
add
wait window "field Replace value = " + alltrim(??field??) timeout 5
or
? alltrim(??field??)
or
before the loop
lnFileHandle = fcreate("debug.txt")
inside the loop
do = fput(filehandle , alltrim(Breeding.??KeyField??) + "Fieldvalue=alltrim(Field??))
after the loop
=fclose(lnFileHandle)
after the program runs go view the file debug.txt with any text editor.

Hope this helps you David W. Grewe
Dave@internationalbid.com
 
David,

Thanks for the response!

litterid is an index that defined in the v_birthdates view. The fields in the view are named slightly different, but the field sizes are the same type and size as the fields that are concatentated together using the + in between them.

What I was looking for was something more like you can do in Access, if you're familar with it.

I can link two tables together, just like this application is doing. Then I can say what fields I want to see and it'll run the query and show me the selected fields.

When I run the query I do get records, but for some reason, the replace is not working. It does a tableupdate at the end.

I'd like to make sure that the data from the one table is actually coming over to the other table. It try what you suggested above and let you know how it works!

Thanks again David!

Snaggs
tribesaddict@swbell.net
Life can only be understood backwards; but it must be lived forwards.
 
Well, the loop part is working and the data is getting replaced, but for some reason it's not saving the data.

In a different section where he does the commit's he has the following code:

IF THISFORM.cpageframe1.page1.ccheckbox1.VALUE=2
SELECT v_birthdates
IF GETNEXTMODIFIED(0)>0
WAIT WINDOW "Updating Birthdates..." NOWAIT
=TABLEUPDATE(.T.,.T.,'v_birthdates')
WAIT CLEAR
ENDIF
ENDIF

I do get the message Updating Birthdates, but it doesn't save the data to the table that v_birthdates is built on.

Prior to this in another section he unrelates the tables that he previously setup then executes the above code.

I looked up the TABLEUPDATE command and it looks like the first command should be a number. I'm not sure why he has .T. in there.

Any ideas on why it's not saving?

Thanks in advance! Snaggs
tribesaddict@swbell.net
Life can only be understood backwards; but it must be lived forwards.
 
I think I got it figured out. You have to have the "SQL Update Table" box checked so the view updated the underlying table.

Doh!

Thanks for the help... Snaggs
tribesaddict@swbell.net
Life can only be understood backwards; but it must be lived forwards.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top