1 (edited by AD1408 2017-09-03 18:31:03)

Topic: 2 Comboboxes not null on same form

I have two comboboxes on same form and same table. One for customers and other for supplier.
Supplier combo shows when issuing a purchase invoice
Customers combo shows when issuing a sale invoice


I wanted make them required field by adding not null on table fields. However, when issuing and inv (i.e. purchase invoice) it asks both combo boxes to be filled even tho one of them not visible.
Is there solution for this please?


Please see the attached sample project:


============================================
EDIT:
After hitting my head few times on the wall I came up with a workaround.
Since both combos are on the same form and when issuing purchase invoice customer details combo is not needed (hidden) and when issuing sale invoice supplier details combo hidden.
I marked supplier combo only as not null and added following code for the sales invoice in order to prevent saving the sale invoice without selecting a customer from customer combo using message box:

procedure frmInvoice_btnInvSave_OnClick (Sender: string; var Cancel: boolean);
begin
  if (frmInvoice.edDBCR.Text = 'Sale') and (frmInvoice.cbSIcustName.dbItemID = -1) Then
  begin
  Cancel := true;
  MessageDlg ('Customer detail fields are required.',mtInformation,MB_OK,0);
  frmInvoice.cbSIcustName.SetFocus
  end;
end;

It seems to be working but I'm not sure if this is the proper way to do it?


Please note that attached sample project is not updated with the above code.

Post's attachments

Attachment icon zz tGrid Field Display 2Combos Not Null.zip 32.66 kb, 362 downloads since 2017-09-02 

Adam
God... please help me become the person my dog thinks I am.

Re: 2 Comboboxes not null on same form

It's ok.

Dmitry.