Board index » delphi » Problem with DBCheckBox Component

Problem with DBCheckBox Component

Hello,

I have a problem when i use DBCheckBox.

I have a form which contains 2 DBCheckBox :

       x tobacco dependence            
       x smoker

and a procedure DBCB_tobaccoClick :

       {if a man is dependent on tobacco, he is a smoker}
       if DBCB_tobacco.Checked then DBCG_smoker.Checked := True;

When the user checks the tobacco DBCheckBox, the smoker DBCheckBox
is checked on the screen.
But, in the table, the 'tobacco' column is update (= true) when
the 'smoker' column is still false.

Thanks for your help.

 

Re:Problem with DBCheckBox Component


Quote
Michel CURE wrote:

> Hello,

> I have a problem when i use DBCheckBox.

> I have a form which contains 2 DBCheckBox :

>        x tobacco dependence
>        x smoker

> and a procedure DBCB_tobaccoClick :

>        {if a man is dependent on tobacco, he is a smoker}
>        if DBCB_tobacco.Checked then DBCG_smoker.Checked := True;

> When the user checks the tobacco DBCheckBox, the smoker DBCheckBox
> is checked on the screen.
> But, in the table, the 'tobacco' column is update (= true) when
> the 'smoker' column is still false.

> Thanks for your help.

Change your code so the table field is being changed not the checkbox.
ie:
 if DBCB_tobacco.Checked then aTable.FieldByName('Smoker').AsBoolean :=
True;

This will change both the table and checkbox.

Re:Problem with DBCheckBox Component


In article <52o29t$...@cyan.wanadoo.fr>, From Michel CURE
<Michel.C...@pop.wanadoo.fr>, the following was written:

Quote
> and a procedure DBCB_tobaccoClick :

> {if a man is dependent on tobacco, he is a smoker}
> if DBCB_tobacco.Checked then DBCG_smoker.Checked := True;

> When the user checks the tobacco DBCheckBox, the smoker DBCheckBox
> is checked on the screen.
> But, in the table, the 'tobacco' column is update (= true) when
> the 'smoker' column is still false.

Try setting the value in the table not in the control:

MyTableSmoker.Value := True;

God Bless,

--
Jay Schwisow j...@weldnet.com
10/01/96 21:46
---------
Using: OUI PRO 1.5.0.2 from http://www.dvorak.com

Re:Problem with DBCheckBox Component


Hello Bob

B>A DisplayFormat of HH:MM gives the basic field a good look until the
B>user enters the field.  But if I put an EditMask (like 99:99) on the
B>field to keep from expanding out to MM/DD/YY HH:MM:SS on entry to the
B>TDBEdit, then the resultant value causes an exception.
B>
B>How can you handle separate TDateTime TFields which need to present
B>to the user as only a Time (or only a Date)?

Sorry I don't have a solution the problem, but I am equally interested
in hearing if you have found a solution since you posted your message.

I use Interbase Local Server. A date mask of !99/99/00;1;_ works fine,
but I have the same problem with the time mask as you do. Also I would
like to be able to have two TDBEdit, that access the same datatime field
but with different display and edit masks( date and time respectively ).

If you or others have any solutions to the problems depicted - please
let me know.

Bye
Peter Naldal

--- WinMail ver. 2.06 Registreret til Peter Naldal

Re:Problem with DBCheckBox Component


Ah, the time-handling problem.

Quote
>A DisplayFormat of HH:MM gives the basic field a good look until the
>user enters the field.  But if I put an EditMask (like 99:99) on the
>field to keep from expanding out to MM/DD/YY HH:MM:SS on entry to the
>TDBEdit, then the resultant value causes an exception.
>How can you handle separate TDateTime TFields which need to present
>to the user as only a Time (or only a Date)?

Yes, the exception (which I would call a bug) is caused by the fact
that "09:00 PM" is not a valid DateTime field!

What I did was to place a tiny bit of code in the OnSetText event
of the TField:

  Sender.AsDateTime := StrToTime(Text);

That prevents the exception.

--
Kevin Davidson (kwdav...@calweb.com)
* In this world of toil and sin
  Your scalp grows bald, but not your chin. - Burma Sig

Other Threads