I have used dc_setrelation numerous times and MOST times it works perfectly. Occasionally it doesn't and I can't tell what stupid thing I'm doing differently (I'm assuming the problem is with me and not Roger's code).
I'm trying now to use it on a report. I have the INVOICES.DBF file open (indexed and with a filter)
index is on i_prodid field and filter is: DbSetFilter( {||substr(i_custid,1,1) <> '|'} )
then right after that I have:
if o_products(.f.,.t.) // open PROUCTS.DBF file
dbsetorder(1) // products->prodid
dbgotop()
dc_SetRelation("invoices", {||invoices->i_prodid} )
When I show data from products file, I always get the data from the first record (in indexed order)
Have same issue if I open invoices and index on date field.
Almost forgot: Alaska 355 and express 244
As always...
thanks
dc_setrelation problem
dc_setrelation problem
There are only 10 kinds of people - those who understand binary and those who don't 

Re: dc_setrelation problem
Hi,
Maybe a dbskip(0) will help after setting your relation.
I'm never using it, I always do a dbseek().
Maybe a dbskip(0) will help after setting your relation.
I'm never using it, I always do a dbseek().
Re: dc_setrelation problem
thanks for the thought, but it didn't work.
I figured the dc_setrelation would be slicker and faster than changing workarea, doing a dbseek, then changing back for every record.
I figured the dc_setrelation would be slicker and faster than changing workarea, doing a dbseek, then changing back for every record.
There are only 10 kinds of people - those who understand binary and those who don't 

Re: dc_setrelation problem
Can you write a small sample program and send it to me?
Include your databases.
Include your databases.
The eXpress train is coming - and it has more cars.
Re: dc_setrelation problem
Changing workarea
What about products->(dbseek( invoices->art_number))
Or in a browse
Dcbrowsecol data {|| products->(dbseek( invoices->art_number)) , products->description }
Dcbrowsecol data {|| products->brand }
If there is another browsecolumn with data from products, you don't need another seek.

What about products->(dbseek( invoices->art_number))
Or in a browse
Dcbrowsecol data {|| products->(dbseek( invoices->art_number)) , products->description }
Dcbrowsecol data {|| products->brand }
If there is another browsecolumn with data from products, you don't need another seek.
Re: dc_setrelation problem
Tried to post this 3 times....
Never knew that 'trick' [ products->(dbseek( invoices->art_number)) ].
When our partner/programmer retired unexpectedly a few years ago wife and I had to learn everything on our own. Only way we could learn was looking at the code and copying ideas/syntax, etc.
Way it was always done in our code was:
select PRODUCTS
dbseek(whatever)
select INVOICES
Thats' why the dc_setrelation seemed so much slicker.
Anyway, Roger: I'd still lik to know what stupid thing I'm doing. I tried attaching the zip of a test prg/exe/dbf/cdx but had problems.
I uploaded it to our ftp site:
http://ftp.ezpos.com/setrelation.zip
In the meantime, I'll try Chris's suggestion.
thanks
Never knew that 'trick' [ products->(dbseek( invoices->art_number)) ].
When our partner/programmer retired unexpectedly a few years ago wife and I had to learn everything on our own. Only way we could learn was looking at the code and copying ideas/syntax, etc.
Way it was always done in our code was:
select PRODUCTS
dbseek(whatever)
select INVOICES
Thats' why the dc_setrelation seemed so much slicker.
Anyway, Roger: I'd still lik to know what stupid thing I'm doing. I tried attaching the zip of a test prg/exe/dbf/cdx but had problems.
I uploaded it to our ftp site:
http://ftp.ezpos.com/setrelation.zip
In the meantime, I'll try Chris's suggestion.
thanks
There are only 10 kinds of people - those who understand binary and those who don't 

-
- Posts: 605
- Joined: Thu Jan 28, 2010 9:11 pm
- Location: Steven Point, Wisconsin USA
- Contact:
Re: dc_setrelation problem
You will find out that also in Xbase++ programming, you generally should alias all function calls like DATABASE->(eof()) or similarly. Otherwise, sometimes the context has not fully switched when your code gets to that area and it could be in the wrong workarea. I had this problem with OrdSetfocus() just as one example when users switched screens and the workarea switch occurred slower than windows responded to the screen change.
Re: dc_setrelation problem
Here's your problem. You were setting a relation to itself.
This is the correct code:
This is the correct code:
Code: Select all
dbselectarea('invoices')
dc_SetRelation("products", {||invoices->i_prodid} )
The eXpress train is coming - and it has more cars.
Re: dc_setrelation problem
Ahhh... knew it haad to be some stupid thing.
thanks
thanks
There are only 10 kinds of people - those who understand binary and those who don't 
