Link to home
Start Free TrialLog in
Avatar of rafaelrgl
rafaelrgl

asked on

GET text from TDBEdit

I would like to get what the user digit on TDBEdit when he´s inserting some field.

Example.

I have some TDBEdit on my form.
The User insert some text on TDBEdit like "RAFAELRGL" when he was inserting.
HOW CAN I GET THAT TEXT.
Avatar of RickJ
RickJ

Try checking the value of DBedit.Text in the keyup event of the DBEdit.
Avatar of Mark Brady
also you could do it 2 ways.  As stated above and also just in case the user presses the ENTER key to enter the info go to the onkeypress event for that control and use add something like....

var
s: string;

begin
if key=#13 then
s:= dbedit1.text; // Now you can do something with the 's' string.  Save it to a file or something.

regards
Elvin
SOLUTION
Avatar of calinutz
calinutz
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also you could do the check in the onExit event of the DBEdit.

Regards
Haha it seems we are all on the same wave length here !

I suppose if Rafaelrg can give us a more detailed description of exactly what he wants and what sort of application this is then we can give a more detailed response.  However, what we have supplied might be ok for his use.

elvin
or in the beforepost event of the dataset directly from the associated tfield . . .
or in the onValidate event of the tfield . . .
or in the inSetText event of the tfield . . .
or . . .
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rafaelrgl

ASKER

I WAS CHECKING MY CODE AND THE PROBLEM IS NOT TBEDIT. TBEDIT.TEXT WORKS GOOD. BUT WHEN I TRY TO DO THIS SENTENCE SQL, DOES NOT WORK. THE FIELD IS EMPTY.

   If DBTELE.DataSource.DataSet.State = dsInsert then
   begin
     try
        Bd.Query_Clientes_Fone.SQL.Clear;
        BD.Query_Clientes_Fone.SQL.Add('insert into TB_USER_FONE');
        BD.Query_Clientes_Fone.SQL.Add('(IDUSUARIO, TELEFONE, TIPO)');
        BD.Query_Clientes_Fone.SQL.Add(' values');
        BD.Query_Clientes_Fone.SQL.Add('(' + DBClientes.Fields[0].Text + ',''' + DBETELE.Text + ''',''' + DBETIPO.Text + ''')');
        Bd.Query_Clientes_Fone.ExecSQL;
     except
     end;
     Bd.Query_Clientes_Fone.SQL.Clear;
     Bd.Query_Clientes_Fone.SQL.Add('select * from TB_USER_FONE WHERE IDUSUARIO = :ID');
     Bd.Query_Clientes_Fone.ExecSQL;
     If not BD.Query_Clientes_Fone.Active Then
     begin
       BD.Query_Clientes_Fone.Open;
     end;
   end else begin
     BD.Query_Clientes_Fone.ApplyUpdates;
   end;
wave length.

DON´T SAY THAT TO OTHER USER ELVIN. I GOT A PROBLEM AND I TRY SO HARD TO MAKE MY CODE WORKS GOOD.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>DBETELE.Text
>DBETIPO.Text

This Fields Above.
Thanks, I DID, it is working now. Here is the code:

   If DBTELE.DataSource.DataSet.State = dsInsert then
   begin
      Bd.SQLClientes_Fone.InsertSQL.Clear;
      BD.SQLClientes_Fone.InsertSQL.Add('insert into TB_USER_FONE');
      BD.SQLClientes_Fone.InsertSQL.Add('(IDUSUARIO, TELEFONE, TIPO, PADRAO)');
      BD.SQLClientes_Fone.InsertSQL.Add(' values');
      BD.SQLClientes_Fone.InsertSQL.Add('(' + DBClientes.Fields[0].Text + ', :TELEFONE, :TIPO, :PADRAO)');
      BD.Query_Clientes_Fone.ApplyUpdates;
   end;
   BD.Query_Clientes_Fone.ApplyUpdates;
what ?  I think you missunderstand my comment but it's probably you poor english so don't worry about it.  I'm glad you got it worked out.
Elvin