751

(22 replies, posted in General)

Hi JB,


Thanks for the extra information.
However, my question remains unanswered. Please see my previous question above post#9
It's about searching in combobox.

752

(22 replies, posted in General)

I wanted add search in combobox on another form (frmInvoice) where combo field contains firstname and lastname. {firstname} {lastname}
It works fine with last name but not with first name or both together.


on frmInvoice
i.e. typing bai finds all persons with lastname Bailey and lists in combo drop-down OK.
However, typing david or david bai doesnt find anything?
There is a David Bailey saved in person db.


Please see the attached sample projects:

753

(21 replies, posted in General)

Thank you so much EHW..........................................................


OnAfterClick did the trick.

754

(21 replies, posted in General)

Thank you so much Dmitry............


I have multiple tabs on form1 with eact tab having tGrid record listing and details of selected grid.


I used just the following to test first tab on form1:

procedure Form1_Button48_OnClick (Sender: string; var Cancel: boolean);
begin
    ClearAllComponents(Form1);
end;

However, it cleared everything on the form1 including unselected tGrid records?
After clearing everything info dialog says "No record selected to delete."


I have c/p your A function to clear all components on form script as it's and after added the above script.
I'm sure that I making a mistake but cannot find it:


procedure ClearAllComponents(Form: TAForm);
var
    i,c : Integer;
begin
    c := Form.ComponentCount - 1;
    For i := 0 to c do
    begin
       IF Form.Components[i] is TdbEdit Then TdbEdit(Form.Components[i]).Clear;
       IF Form.Components[i] is TdbEditCount Then TdbEditCount(Form.Components[i]).Clear;
       IF Form.Components[i] is TdbMemo Then TdbMemo(Form.Components[i]).Clear;
       IF Form.Components[i] is TdbComboBox Then TdbComboBox(Form.Components[i]).dbItemID := -1;
       IF Form.Components[i] is TdbCheckBox Then TdbCheckBox(Form.Components[i]).State := TdbCheckBox(Form.Components[i]).dbDefaultState;
       IF Form.Components[i] is TdbDateTimePicker Then TdbDateTimePicker(Form.Components[i]).Checked := False;
       IF Form.Components[i] is TdbImageDataBase Then TdbImageDataBase(Form.Components[i]).Clear;
       IF Form.Components[i] is TdbMonthCalendar Then TdbMonthCalendar(Form.Components[i]).Date := now;
       IF Form.Components[i] is TdbStringGridEx Then TdbStringGridEx(Form.Components[i]).ClearRows;
       IF Form.Components[i] is TdbFileToDatabase Then
       begin
           TdbFileToDatabase(Form.Components[i]).Text := '';
           TdbFileToDatabase(Form.Components[i]).dbFileName := '';
       end;
    end;
end;


// --------->> form1 COMPANY tab
procedure Form1_Button48_OnClick (Sender: string; var Cancel: boolean);
begin
    ClearAllComponents(Form1);
end;

// --------->> form1 CUSTOMERS tab
procedure Form1_Button3_OnClick (Sender: string; var Cancel: boolean);
begin
    ClearAllComponents(Form1);
end;

// --------->> form1 PRODUCTS tab
procedure Form1_Button6_OnClick (Sender: string; var Cancel: boolean);
begin
    ClearAllComponents(Form1);
end;

755

(21 replies, posted in General)

Hi Dmitry,


Is there any solution please?


AD1408 wrote:

Hi EHW,


Thanks for your kind help...... Always appreciated.


Lets hope Dmitry provides the remaining solution for clearing remaining field types after delete.

If possible, it needs to clear images, checkboxes, dates, memo and comboboxes field types too

756

(21 replies, posted in General)

Hi EHW,


Thanks for your kind help...... Always appreciated.


Lets hope Dmitry provides the remaining solution for clearing remaining field types after delete.

If possible, it needs to clear images, checkboxes, dates, memo and comboboxes field types too

757

(2 replies, posted in General)

I manage to solve out the issue by using a button for lookups with an action new record and updated the script as follows:

procedure MenuClick4 (Sender: string);
begin
     form1.btnLookups.click;
end;

I'd have preferred a direct syntax on menu item for new record. Perhaps it's not supported as yet until menu system implemented.

758

(2 replies, posted in General)

I have posted the following on a different thread with another question, perhaps it's best to post on a new thread here


I have a menu item to launch Lookups form and this form uses MVD v3.1 tGrid with on grid edit only for adding new records.

showModal doesn't work. It needs newRecord action.

procedure MenuClick4 (Sender: string);
begin
     frmLookups.'NewRecord';
end;

the NewRecord in above script is not accepted. What's the correct action name for NewRecord please?

759

(21 replies, posted in General)

Hi JB,


Jezebel from hell asked me to do some accounting app for her and she is very demanding...


On serious note, I still need a help on clearing images, checkboxes, dates and comboboxes field types as stated on my previous post #9.

760

(1 replies, posted in General)

Added onchange event and it seems to be working atm.

procedure Form1_tgSearchPurchInv_OnChange (Sender: string);
begin
  form1.edSaleTabPurchInvTotals.Value:= Form1.tgSearchPurchInv.Columns[6].Footer.FormulaValue;
end;

761

(21 replies, posted in General)

np JB.


Yes, EHW script is good for clearing multiple fields.


If possible, it needs to clear images, checkboxes, dates and comboboxes field types too beside textboxes.


The following clears tGrid OK:

procedure Form1_tgSearch_Customers_OnChange (Sender: string);
begin
   Form1.tgSearchCustInvItems.ClearRows;
end;

To clear images, checkboxes, dates and comboboxes I have tried to add EHW script but it didn't work:

procedure Form1_Button8_OnClick (Sender: string; var Cancel: boolean);
var i : Integer;
begin
       For i := 0 to Form1.ComponentCount -1 do
       IF Form1.Components[i] is TdbEdit Then TdbEdit(Form1.Components[i]).Clear;
end;

begin
       For i := 0 to Form1.ComponentCount -1 do
       IF Form1.Components[i] is TCheckBox Then TCheckBox (Form1.Components[i]).Clear;
end;

begin
       For i := 0 to Form1.ComponentCount -1 do
       IF Form1.Components[i] is TComboBox Then TComboBox (Form1.Components[i]).Clear;
end;

begin
       For i := 0 to Form1.ComponentCount -1 do
       IF Form1.Components[i] is TDateTime Then TDateTime (Form1.Components[i]).Clear;
end;

begin
       For i := 0 to Form1.ComponentCount -1 do
       IF Form1.Components[i] is TImage Then TImage (Form1.Components[i]).Clear;
end;

762

(1 replies, posted in General)

procedure Form1_OnShow (Sender: string; Action: string);
  begin
    Form1.edSaleTabSaleInvTotals.Value := Form1.tgSearchSaleInv.Columns[9].Footer.FormulaValue;
    Form1.edSaleTabPurchInvTotals.Value := Form1.tgSearchPurchInv.Columns[6].Footer.FormulaValue;
  end;


procedure CalculateTotal;

begin
    Form1.edSaleTabDifference.Value := Form1.edSaleTabSaleInvTotals.value - Form1.edSaleTabPurchInvTotals.Value;
end;

procedure Form1_edSaleTabSaleInvTotals_OnChange (Sender: string);
 begin
    CalculateTotal;
 end;

 procedure Form1_edSaleTabPurchInvTotals_OnChange (Sender: string);
 begin
    CalculateTotal;
 end;

The above code copies tGrids footers and calc.



"edSaleTabPurchInvTotals" textbox field (please see img below) needs an update script  on change of "t.tgSearchPurchInv.Columns[6].Footer"
Unfortunately, I failed to come up with an update script.


https://s28.postimg.org/vc7eo4f99/zzz_Test9.png

763

(5 replies, posted in General)

Derek,


Thank you VERY much for quick reply...............................


I tried many variations without var and I couldn't get it working.
Your code with var works fine.

764

(5 replies, posted in General)

AD1408 wrote:

Hi Derek,
..........

I got the dates was left out among image fields but couldn't convert the image script below to 'nested select' script:

Form1.dbiSearchDetCustImage.LoadFromDatabase('Customers', 'image', Form1.tgSearch_Invoices.dbItemID);

Derek, I guess the above for Dmitry

765

(21 replies, posted in General)

Hi JB,


Thanks a lot...


I was looking for short script as in EHW script to handle many fields. Please see the post #1

766

(5 replies, posted in General)

Hi Derek,


Thank you sooooooooo much...................


I got the dates was left out among image fields but couldn't convert the image script below to 'nested select' script:

Form1.dbiSearchDetCustImage.LoadFromDatabase('Customers', 'image', Form1.tgSearch_Invoices.dbItemID);

767

(5 replies, posted in General)

I used same script for showing customers details on form1 customers and invoices tab.
Script works for customers tab but not on invoices tab.
Difference is that inv tgGrid on Invoices tab displaying data from InvoiceHeader table therefore invoice details displayed, however customer details are not .
I have linked InvoiceHeader table to Customers table but couldn't get it working.


Please see the attached sample project:

768

(21 replies, posted in General)

Thank you so much EHW and Dmitry...............................


Assuming I applied the code correctly, not all cleared after a record deleted.
Please see reference images below:
Before deleting Paul Low record
https://s28.postimg.org/7umngf68d/zzz_Test7.png
After delete:
https://s28.postimg.org/rvg3kzg25/zzz_Test8.png


Image, date, combobox fields and associated tGrid is not cleared?


-----------------------------------
ps/.
I didn't want to start a new thread for this small issue of mine.
I have a menu item to launch Lookups form and this form uses MVD v3.1 tGrid with on grid edit only.

showModal doesn't work. It needs newRecord action.

procedure MenuClick4 (Sender: string);
begin
     frmLookups.'NewRecord';
end;

the NewRecord in above script is not accepted. What's the correct word please?

769

(21 replies, posted in General)

Is there shorter way of clearing fields after deleting a record?


It's ok using .clear for few fields but when there are too many fields (i.e. over 500) writing a line for each field not an attractive proposition.


Below clears only a single field.

procedure Form1_tgSearch_Customers_OnChange (Sender: string);
begin
   Form1.EdSearch_InfoName.Clear;
end;

I have to add over 500 lines similar to
Form1.EdSearch_InfoName.Clear;


Perhaps there is a shorter way of achieving the task?

770

(8 replies, posted in General)

Thank you so much Dmitry.....................

771

(8 replies, posted in General)

AD1408 wrote:

Thanks Dmitry,


I tried following but get "List index out of bounds (1)" warning

procedure frmSaleTransHist_OnShow (Sender: string);
  begin
    frmSaleTransHist.edSaleTransInvTotal.Value := Form1.tgSearchSaleInv.Columns[9].Footer.FormulaValue;
  end;

???

Edit:
What I'm trying to do is copy tGrid footer values to another form and do calculations there
Please see the Updated sample project 2 with error and calc attached:

772

(8 replies, posted in General)

Thanks Dmitry,


I tried following but get "List index out of bounds (1)" warning

procedure frmSaleTransHist_OnShow (Sender: string);
  begin
    frmSaleTransHist.edSaleTransInvTotal.Value := Form1.tgSearchSaleInv.Columns[9].Footer.FormulaValue;
  end;

Actually, I wanted copy form1/tgSearchSaleInv footer value.
Corrected frmSaleTransHist component name to edSaleTransInvTotal

773

(8 replies, posted in General)

This time I wanted to copy tGrid footer value from one form into another form edit field with it's decimals and thousands separator.


Source frmSaleInv tGrid, target frmSaleTransHist / edSaleInvTotal field. I tried the following but didn't work:

procedure frmSaleTransHist_OnShow (Sender: string);

    begin
    frmSaleTransHist.edSaleTransInvTotal.Value := frmSaleInv.tgSaleInv.Columns[9].Footer.FormulaValue;

    end;

Please see the attached sample project:

774

(48 replies, posted in General)

Looks like I made two simple mistake.


Thanks a lot EHW........................

775

(48 replies, posted in General)

ehwagner wrote:

Attach your project Adam and I'll take a look at it.


Thanks EHW...


Here is the sample project: