We help IT Professionals succeed at work.

GET text from TDBEdit

rafaelrgl
rafaelrgl asked
on
Medium Priority
446 Views
Last Modified: 2010-04-04
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.
Comment
Watch Question

Commented:
Try checking the value of DBedit.Text in the keyup event of the DBEdit.
Mark BradyPrincipal Data Engineer
CERTIFIED EXPERT

Commented:
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
Commented:
var
 s:string;
begin
...
s:=DBEdit1.Text;
...


Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Commented:
Also you could do the check in the onExit event of the DBEdit.

Regards
Mark BradyPrincipal Data Engineer
CERTIFIED EXPERT

Commented:
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
Top Expert 2004

Commented:
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 . . .
Mark BradyPrincipal Data Engineer
CERTIFIED EXPERT
Commented:
Exactly my point Kretzschmar :)
CERTIFIED EXPERT
Commented:
If you are using cached updates, you could use the field's OldValue and CurValue properties to get info about the field values.
Don't use
TabelNameDataField.Value
It will give the available data in the datafield until you post the new vaule. Even if you make changes on the dbText it will reflect only on dbText not on datafield until you post it.

sun4sunday

Author

Commented:
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;

Author

Commented:
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.
Top Expert 2004
Commented:
>THE FIELD IS EMPTY.

which field?
>DBClientes.Fields[0].Text
>DBETELE.Text
>DBETIPO.Text

meikl ;-)

p.s.: there is no need to write all in capital letters (is harder to read)

Author

Commented:
>DBETELE.Text
>DBETIPO.Text

This Fields Above.

Author

Commented:
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;
Mark BradyPrincipal Data Engineer
CERTIFIED EXPERT

Commented:
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
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.