Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 10 total
Thread OnCalcFields like field
Mon, Nov 26 2018 4:14 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

I'm pretty sure this or something like it is in the suggestions pile but just in case it isn't....

I'd like an extension to generated / computed to allow an OnCalcFields like operation where I could plonk SQL to do the necessary lookups via an sql statement. I'd be happy to see an enforced "if there are several rows returned just grab the top one" type of operation.

If it is there any idea of when it might see the light of day?

Roy Lambert
Mon, Nov 26 2018 4:23 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< I'd like an extension to generated / computed to allow an OnCalcFields like operation where I could plonk SQL to do the necessary lookups via an sql statement. I'd be happy to see an enforced "if there are several rows returned just grab the top one" type of operation. >>

Why not just use an actual query with RequestSensitive=True and the necessary SQL calculations ?

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Nov 27 2018 5:07 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim

><< I'd like an extension to generated / computed to allow an OnCalcFields like operation where I could plonk SQL to do the necessary lookups via an sql statement. I'd be happy to see an enforced "if there are several rows returned just grab the top one" type of operation. >>
>
>Why not just use an actual query with RequestSensitive=True and the necessary SQL calculations ?

Because I'm using a table component not a query. I know its pretty luddite of me but I find tables better for some aspects of user interface (eg flipping indices). Also I'd have to rewrite some of my homebrew components that rely on the class being a table rather than a query. Now you've suggested a query I'll have a look and see how easy it will be to convert from a table to a generic TDataset.

The final point is that when I have these sort of requirements its a lot easier to just reference a column name in a query or table than have to start including subselects or oncalc fields in the program. Call it lazy of me if you like.

Roy
Tue, Nov 27 2018 8:46 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim


Just been experimenting, altered my lookup system to use TEDBDataset and then test for wether its a query or table as source, and if query then extract table name from the sql. It works BUT with a table then as soon as the foreign key field I'm doing a lookup on is altered the OnCalcFields fires and I'm shown the new looked up value whilst I'm still editing. With a query I have to post the record first.

I could use the query's OnCalcFields but that rather defeats moving to a query. Am I missing some nice little switch or property that will do what I want?

Roy Lambert
Mon, Dec 3 2018 10:49 AMPermanent Link

Adam Brett

Orixa Systems

Roy

I may not be understanding exactly what you are trying to achieve, but how about the AfterScroll event.

This is triggered the moment you change to a new row & have the reference data I think you need to populate a look up. Note that I am not sure whether AfterScroll is triggered AfterOpen, so you might have to add the lookup procedure in both methods.
Tue, Dec 4 2018 2:32 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Adam

>I may not be understanding exactly what you are trying to achieve, but how about the AfterScroll event.
>
>This is triggered the moment you change to a new row & have the reference data I think you need to populate a look up. Note that I am not sure whether AfterScroll is triggered AfterOpen, so you might have to add the lookup procedure in both methods.

OnCalcFields works well. Think of entering a code (nominal, stock or whatever) and when its entered and you leave that field the text description is shown (typically on a DBText). Rather than a lookup I could do a calculation or whatever in the OnCalcFields. The current sql COMPUTED type doesn't allow lookups. I could use Tim's suggestion but that requires the record to be posted hence you can have a code with a non-matching description to cause confusion.

What I'm hoping for is a way to do it all as part of the database so I don't need multiple OnCalcField events splattered around.

Roy
Mon, Dec 10 2018 3:33 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< I could use the query's OnCalcFields but that rather defeats moving to a query. Am I missing some nice little switch or property that will do what I want? >>

No, unfortunately that's how the computed columns work: EDB has to get the update before it can do anything with it, and it won't get the update until you post the row modifications.

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Dec 11 2018 3:08 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim

>No, unfortunately that's how the computed columns work: EDB has to get the update before it can do anything with it, and it won't get the update until you post the row modifications.

Ah well tables and OnCalcFields it is then Frown

Roy
Tue, Dec 11 2018 5:56 AMPermanent Link

Adam Brett

Orixa Systems

Roy

In that situation I use OnValidate. This is triggered whenever the user modifies a field.

Perhaps I have misunderstood the problem, but code at that point can do some of what you seem to want.
Tue, Dec 11 2018 8:18 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Adam

>In that situation I use OnValidate. This is triggered whenever the user modifies a field.
>
>Perhaps I have misunderstood the problem, but code at that point can do some of what you seem to want.

Interesting idea. I use OnCalcFields because that gives me one place for each table to put all the code, and it works when displaying in a grid. OnValidate only works when you're editing the field and is generally on a field by field basis so in the specific case that prompted the question would have 4 functions rather than 1.

Roy
Image