576

(4 replies, posted in General)

How can I hide combobox items on a button click?

I have two forms
Form1 with Button1 and Button2
Form 2 has a combobox with Item1, Item2, Item3, Item4. Combobox items (data) added manually in SQLiteStudio.


If Button1 clicked
Show only combobox Item1 and Item 3
If Button2 clicked
Show only combobox Item1, Item 2 and Item4


I couldn't translate the above into MVD script that works?

577

(6 replies, posted in General)

Does the attached come closer to what you want?


Hi Derek,


I wish I could have said big yes, but unfortunately it's not. However, I'm truly grateful for your kind efforts of help... Always...


I'm not sure if you have checked out my latest sample project named "Save as new record Test.zip " on post #3. There, all those show/hide, enable/disable events quite close to what I'm trying to achieve with the exception of hiding some Invoice Type combo items.
1. Hiding when adding new record. Since we can only issue refund for something received, I wanted to hide "Sale", "Sale Refund" and "Purchase Refund" combo items when we are adding a new purchase invoice. Smilarly, hiding "Purchase", "Sale Refund" and "Purchase Refund" combo items when we are adding a new sale invoice.
2. When user clicks on Edit selected Purchase Invoice, Invoice Type combo item "Sale Refund" should be hidden preventing user saving it as a sale refund by mistake.
3. When user clicks on Edit selected Sale Invoice, Invoice Type combo item "Purchase Refund" should be hidden preventing user saving it as a purchase refund by mistake.


Key point is when issuing a refund against an invoice (fully or partially) refund should be saved as a new record, not overwriting existing record as it currently does. Please see images (1,2,3 and 4) on the post #3. Hence the title of the post most important part is to achieve saving existing record as different/new record which I have no idea how to do it with using same table and form. Perhaps post title should have been Saving existing record as an another record.


Required overlying objects on the form can be done later on as needed. It's easier to manage them during work/test phase. I left Refund numbers panels separate atm but they will be overlaid once all working. I usually do cosmetics on later stages of the project .

578

(6 replies, posted in General)

Hi Derek,


Thank you very much for the sample.......................


Last couple of days I have been trying to achieve desired solution.
I have changed for all show/hide, disable/enable events around Invoice type combo onChange.


However, saving existing record (issuing a refund against existing sale/purchase invoice) issue is still outstanding. The way I'm trying to do this task as illustrated on the image below:

https://s4.postimg.org/wqmzoead9/zzzzz_Temp36.png

579

(6 replies, posted in General)

I have tried something without success. Idea is converting sale/purchase invoice into refund and saving it as a new record next to original invoice sale/purchase inv record.


Please see the attached sample project

580

(2 replies, posted in General)

Hi Derek,


Thank you very much......................
Truly appreciated..............................

581

(2 replies, posted in General)

I tried to display appropriate combo box values. If I click on Add or Edit sale invoice button on form1, I wanted to display 'Sale' combo value in combo box Inv Type on Invoice form and so on.


Tried buttons after click and frmInvoice onShow events but both didn't work.

procedure Form1_btnPurchEdit_OnAfterClick (Sender: string);
begin
  frmInvoice.cbInvoiceDBCR.Text := 'Purchase';
end;

procedure Form1_btnPurchAdd_OnAfterClick (Sender: string);
begin
  frmInvoice.cbInvoiceDBCR.Text := 'Purchase';
end;


procedure Form1_btnSaleEditRefund_OnAfterClick (Sender: string);
begin
  frmInvoice.cbInvoiceDBCR.Text := 'Purchase Refund';
end;
....

procedure frmInvoice_OnShow (Sender: string; Action: string);
begin
  if Form1.btnPurchAdd.click then
  begin
    frmInvoice.cbInvoiceDBCR.Text := 'Purchase';
  end;
end;
..........

Ps/. I used Derek's custom line on combobox.


Please see the attached sample project if needed

582

(3 replies, posted in General)

Hi Derek,


Thank you very much for your help... Truly appreciated.....
Your solution my be better than mine and something to learn from.


My solution was this. It seems to be working but not altogether sure about it tho.

(DbCr.dbcr= "Sale") or  (DbCr.dbcr= "Sale Refund") 
(DbCr.dbcr= "Purchase") or  (DbCr.dbcr= "Purchase Refund") 

583

(3 replies, posted in General)

I'm trying to use one form for all invoices and displaying them on their receptive tGrids using combobox filter for each type on tGrid settings filter field. Tried few variations without any success.


edit:
it's sorted.

584

(6 replies, posted in General)

Thank you very much for the solution and quick reply..............................................


Looks like my logic is still rotten in these matters.

585

(6 replies, posted in General)

Hi EHW,


Looks like I have overlooked some items.

Adding sale or refund inv works fine.
However, converting (changing) sele inv to refund inv and refund inv to sale inv using DB/CR combo is not.


1. Entered sale  then changed DC/CR combo to refund. Discount and Deliv Cost fields values is not converted to minus:
https://s15.postimg.org/yyhjhd097/zzzzz_Temp34.png



1. Entered refund then changed DC/CR combo to sale. Discount and Deliv Cost fields values is not converted to positive numbers:
https://s24.postimg.org/m5lhj19id/zzzzz_Temp35.png


I have tried to move your code under DBCR combo on change with else but didn't work:

procedure frmSalesInv_cbSaleInvDBCR_OnChange (Sender: string); // SALE or REFUND
begin
  If (frmSalesInv.cbSaleInvDBCR.dbItemID = 2) and (frmSalesInv.edSalesInvDelivCost.Value > 0) then
      begin
      frmSalesInv.edSalesInvDelivCost.Value := 0 - frmSalesInv.edSalesInvDelivCost.Value;
      CalculateTotal;
      end else
      begin
      frmSalesInv.cbSaleInvDBCR.dbItemID := 1;
      frmSalesInv.edSalesInvDelivCost.Value;
      CalculateTotal;
      end;

  If (frmSalesInv.cbSaleInvDBCR.dbItemID = 2) and (frmSalesInv.edSalesInvDiscount.Value > 0) then
      begin
      frmSalesInv.edSalesInvDiscount.Value := 0 - frmSalesInv.edSalesInvDiscount.value;
      CalculateTotal;
      end else
      frmSalesInv.cbSaleInvDBCR.dbItemID := 1;
      frmSalesInv.edSalesInvDiscount.Value;
      CalculateTotal;
end;

586

(6 replies, posted in General)

Hi EHW,


Great stuff as usual.................
Thank you very much.............
Truly appreciated....................

587

(6 replies, posted in General)

Sorted calc fields.. but cannot get Discount and Deliv Cost values displayed as minus (-) values.


tried following but no luck

frmSalesInv.edSalesInvDelivCost.Value := - (frmSalesInv.edSalesInvDelivCost.Value);
frmSalesInv.edSalesInvDiscount.value := - (frmSalesInv.edSalesInvDiscount.value);

588

(6 replies, posted in General)

I just couldn't work out the way to display refund (Cr.) invoice values in minus. I got some OK (Thanks to Derek's sample) but some not as highlighted on the image below. As a result calcs return incorrect values.


https://s27.postimg.org/qndrs2hdv/zzzzz_Temp33.png


Please see the attached sample project.
------------------------

589

(7 replies, posted in General)

Hi Derek,
Nice one...  Truly appreciated..........
Adding a message for selecting actual item is very thoughtful of you.


Hi JB,
Thanks for the info.............

590

(7 replies, posted in General)

Thanks a lot guys....

derek wrote:

Hi Adam,
Is this so it's like some sort of hint for the user?
Derek

Yes Derek, instead of showing blank or no space, having text line something like "Please select one"

591

(7 replies, posted in General)

Is it possible to add a custom text on ComboBox first empty Item?

592

(2 replies, posted in General)

Hi Math,


Thank you very much..............
Still an absolute beginner I'm.. Couldn't think wrapping.
Your quick help truly appreciated.............

593

(2 replies, posted in General)

I was trying to include two condition (boolean and Combobox) to perform the action with the below:

procedure frmSalesInv_btnCalc_OnClick (Sender: string; var Cancel: boolean; vrate:integer);
begin
vrate := sqlexecute('select taxrate from taxrates where id = '+frmSalesInv.cbSaleInvTaxRate.sqlvalue);
  if frmSalesInv.cBoxSale.checked = True and        // if it's a DB line
     frmSalesInv.cbSaleInvDBCR.dbItemID = 0 then
    begin
     ...
    end;

  if  frmSalesInv.cBoxSale.checked = True and     // if it's a CR line
      frmSalesInv.cbSaleInvDBCR.dbItemID = 1 then
    begin
      ...
    end;
end;

It didn't work. I couldn't get the right syntax/structure to join both conditions?
I'm trying to convert sale into credit inv (refund) on same inv form.

594

(3 replies, posted in General)

Hi EHW,


Thank you very much............
Truly appreciated.............

595

(3 replies, posted in General)

Still couldn't resolve clearing tGrid rows issue.
Perhaps I couldn't explain my issue clearly on my first post above. This time I try with the image below:


https://s28.postimg.org/gfct3fib1/zzzzz_Temp31.png

596

(2 replies, posted in General)

Hi Dmitry,


Thank you very much.................
Magic customer ratings formula........
Truly appreciated............

597

(2 replies, posted in General)

My one cell brain couldn't come up with solution....
What I like to do is rate customers according to amount they spent - to date. Rating added and updated automatically without any manual interference other than defining ratings in lookups tGrid.
Is this doable?


Please see the attached sample project as a work base

598

(14 replies, posted in General)

Thank you very much EHW...............
Nice one..............
I also thank you for showing (code) how to avoid saving blank records where child records involved by clicking on cancel.

599

(14 replies, posted in General)

Hi EHW,


At my end I cannot get checkboxes checked on running app. Please see image below as ref. Most likely I'm missing something?
https://s30.postimg.org/m0gt6rh9t/zzzzz_Temp30.png


On save front, I really don't want auto save. Save should be done when user wants to save by clicking on save button as they may be doing some test pw generations and they wouldn't want to save every test etc. Please don't misunderstand me. I'm not complaining. In fact I'm truly grateful for your all kind help. Would it be possible within your limited time to take of auto-save please?
So record is not saved after clicking on "generate passwords" button but after user clicks on "save" button - in this case button3.

600

(14 replies, posted in General)

Thank you soooooooo much EHW....................
Great Stuff..... truly appreciated............


Using editable tGRid instead of edit fields is a better approach. One reason I didn't use editable tGrid is that I didn't know limiting edit columns were possible or not as I wanted only 'Used' column to be editable. However, it's not a show stopper.


My intention of using 'Save' plus 'Save and Close' buttons was:
When user clicks on 'Save' button generated passwords are saved as a set, all fields and tGrid cleared except quatity and checkboxes so that it's ready to generate next passwords set.   'Save and Close' button saves generated passwords set and closes frmPwGen. I think it's my bad that I didn't make it clear. However, it's not big deal. It's fine with just usual save and close button.
I couldn't understand that as to why you have used dummy save button which saves the record before user clicks on save or save and close buttons?


'No similar characters' checkbox meant for not having same characters within same password, all characters would be unique within same password. Again, it's not that important as your code generates strong passwords with already applied properties. Nice work,  I'll take that option out.
On checkboxes I have another miss. I wanted all password construction properties checkboxes default state checked but I forgot to apply it on sample project. I changed them on MVD properties checked to true but it didn't work as they seems to be tied in within the code. Tried some alterations in code but no success.