dc_setrelation problem

This forum is for eXpress++ general support.
Post Reply
Message
Author
BruceN
Posts: 280
Joined: Thu Jan 28, 2010 7:46 am
Location: Slidell, LA

dc_setrelation problem

#1 Post by BruceN »

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
There are only 10 kinds of people - those who understand binary and those who don't :)

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: dc_setrelation problem

#2 Post by skiman »

Hi,

Maybe a dbskip(0) will help after setting your relation.

I'm never using it, I always do a dbseek().
Best regards,

Chris.
www.aboservice.be

BruceN
Posts: 280
Joined: Thu Jan 28, 2010 7:46 am
Location: Slidell, LA

Re: dc_setrelation problem

#3 Post by BruceN »

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.
There are only 10 kinds of people - those who understand binary and those who don't :)

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: dc_setrelation problem

#4 Post by rdonnay »

Can you write a small sample program and send it to me?

Include your databases.
The eXpress train is coming - and it has more cars.

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: dc_setrelation problem

#5 Post by skiman »

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.
Best regards,

Chris.
www.aboservice.be

BruceN
Posts: 280
Joined: Thu Jan 28, 2010 7:46 am
Location: Slidell, LA

Re: dc_setrelation problem

#6 Post by BruceN »

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
There are only 10 kinds of people - those who understand binary and those who don't :)

Cliff Wiernik
Posts: 605
Joined: Thu Jan 28, 2010 9:11 pm
Location: Steven Point, Wisconsin USA
Contact:

Re: dc_setrelation problem

#7 Post by Cliff Wiernik »

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.

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: dc_setrelation problem

#8 Post by rdonnay »

Here's your problem. You were setting a relation to itself.

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.

BruceN
Posts: 280
Joined: Thu Jan 28, 2010 7:46 am
Location: Slidell, LA

Re: dc_setrelation problem

#9 Post by BruceN »

Ahhh... knew it haad to be some stupid thing.

thanks
There are only 10 kinds of people - those who understand binary and those who don't :)

Post Reply