Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread CalcFields
Tue, Feb 2 2010 10:22 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

I have a table (Companies) which is used in a base form (CompaniesForm) and a number of inherited forms. In one of them I have introduced a calculated field to show in a checkbox in a TDBAdvGrid when a  company is included in a specific project. A stringlist is also maintained of the company (CompanyID) codes. My problem comes when ticking or unticking the checkbox in the column. It takes around .6 - .7 secs I traced it down to the call to Companies.Refresh. I tried changing that to Companies.Edit;Companies.Cancel; and it works but a) isn't suitable for multi user use and b) is just as slow

I need something that will trigger the oncalcfields event for a specific row in the table, or a totally different approach. I'm experimenting with the enhanced CREATE TABLE AS so any other suggestions?

procedure Tcp_CompaniesForm.CompaniesCalcFields(DataSet: TDataSet);
var
Junk: integer;
begin
inherited;
Companies_xInProject.AsBoolean := CompanyIP.Find(Companies_ID.AsString, Junk);
end;

Roy Lambert
Tue, Feb 2 2010 7:19 PMPermanent Link

Richard Harding
Hi Roy,

>>I have a table (Companies) which is used in a base form (CompaniesForm) and a number of
inherited forms. In one of them I have introduced a calculated field to show in a checkbox
in a TDBAdvGrid when a  company is included in a specific project. A stringlist is also
maintained of the company (CompanyID) codes.

What do your DB tables look like?  Is it anything at all like this?

Companies (ID, . . . . . . )
Projects(ID, . . . . .)
ProjectCompanies(ID, ProjectID, CompanyID)

What information is the form showing?  Is it a form with project information and the user
selects the associated companies for that project from a list of companies?  Have I got
that even remotely close?

Richard Harding
Wed, Feb 3 2010 2:19 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Richard

>What do your DB tables look like? Is it anything at all like this?
>
>Companies (ID, . . . . . . )
>Projects(ID, . . . . .)
>ProjectCompanies(ID, ProjectID, CompanyID)
>
>What information is the form showing? Is it a form with project information and the user
>selects the associated companies for that project from a list of companies? Have I got
>that even remotely close?

Pretty  much, but naturally, its more complex Smiley For example I didn't mention the contacts table.

Roy Lambert
Wed, Feb 3 2010 6:58 PMPermanent Link

Richard Harding
Roy,

Given the tables look something like this:

Companies (ID, . . . . . . )
Projects(ID, . . . . .)
ProjectCompanies(ID, ProjectID, CompanyID)

and that the Project form shows project information and the user selects the associated
companies for that project from a list of companies.

Not sure if I understand - - - however, is it a matter of having a panel with project
details and a grid that lists all the associated companies?
I do either one of the following.

1. Choose a company from a drop down list for each row of the grid.
2. Choose a company from a dialog box for each row of the grid.
3. Use a checked listbox (or similar) in a dialog box to select the required companies for
the project.  This updates the ProjectCompanies when the dialog is closed.

For my project database system, I also have a Role table which may contain entries such as
Surveyor, Accountant, Solicitor, Pest Inspector, Town
Planner, Local Government and so on.

A contact (which may be a company) may be assigned any number of roles. (ContactRoles
table).   So users can assign the roles (for example Town Planner) to a project and then
select the Town Planner from the Town Planner subset of contacts.

Richard Harding
Thu, Feb 4 2010 4:11 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Richard


Near, but so far away Smiley The form I use is essentially the same as the company form, and in "research" mode (which is where I have the problem) I add a tick box into the grid displaying the company names. If its ticked the company is in the specific project, if not then not. To show the tick status I have a calculated column. There's an event on the grid (a TDBAdvGrid) when the checkbox is clicked and I use that to add / remove the company ID from a sorted stringlist. The OnCalcFields event uses that stringlist to determine wether the boolean field is true or false and thus the check box is set.

The only way I've found to get the calculated field recalculated is to either refresh the table or edit/cancel the record both of which operations take to much time.

What I'm thinking of doing is having a memory table with the company ID and a boolean field. This can then be tied to the company table in a master-detail arrangement and the checkbox directly edited thus bypassing the need for calcfields.

Roy Lambert
Image