Board index » delphi » Automatically updating fields using DBEdit

Automatically updating fields using DBEdit

Dear all,

I'm trying to update a record in a database (Access). My latest attempt is
listed below. The data is written ok to the DBEdit fields, but when the
record is updated the data changes to a strange number. I'd really
appreciate help. Please answer by mail.

Peder

  Form4.Table1.Active:=true;
  Form4.Visible:=true;
  Form4.BringToFront;
  Form4.DBNavigator1.BtnClick(nbInsert); // new entry
  Form4.DBNavigator1.BtnClick(nbEdit); // permits editing
  Form4.DBEdit1.Text:=Edit11.Text;

  Form4.DBEdit2.SetFocus; Form4.DBEdit2.Text:=Label29.Caption; // QL
  Form4.DBEdit3.SetFocus; Form4.DBEdit3.Text:=Label28.Caption; // QS
  Form4.DBEdit4.SetFocus; Form4.DBEdit4.Text:=Edit7.Text+' 00:00:00'; //
Date
  Form4.DBEdit5.SetFocus; Form4.DBEdit5.Text:=Label4.Caption; // Q

//  Form4.DBNavigator1.BtnClick(nbPost); // post entry

 

Re:Automatically updating fields using DBEdit


Quote
On Tue, 15 Jan 2002 17:03:05 +0100, Tony wrote:

Which fields are 'strange numbers'
What are their data types in access ?
An example of what the DBEdits contained to what finally ended up in
the record would be useful.
P.S. This is a very expensive way of updating the database, Why didn't
you use a query component ?
Quote
>Dear all,

>I'm trying to update a record in a database (Access). My latest attempt is
>listed below. The data is written ok to the DBEdit fields, but when the
>record is updated the data changes to a strange number. I'd really
>appreciate help. Please answer by mail.

>Peder

>  Form4.Table1.Active:=true;
>  Form4.Visible:=true;
>  Form4.BringToFront;
>  Form4.DBNavigator1.BtnClick(nbInsert); // new entry
>  Form4.DBNavigator1.BtnClick(nbEdit); // permits editing
>  Form4.DBEdit1.Text:=Edit11.Text;

>  Form4.DBEdit2.SetFocus; Form4.DBEdit2.Text:=Label29.Caption; // QL
>  Form4.DBEdit3.SetFocus; Form4.DBEdit3.Text:=Label28.Caption; // QS
>  Form4.DBEdit4.SetFocus; Form4.DBEdit4.Text:=Edit7.Text+' 00:00:00'; //
>Date
>  Form4.DBEdit5.SetFocus; Form4.DBEdit5.Text:=Label4.Caption; // Q

>//  Form4.DBNavigator1.BtnClick(nbPost); // post entry

Re:Automatically updating fields using DBEdit


Quote
Peder Skov-Hansen wrote:

Peder,

Get rid of these statements:

Quote
>   Form4.DBNavigator1.BtnClick(nbInsert); // new entry
>   Form4.DBNavigator1.BtnClick(nbEdit); // permits editing

Instead code :

Table1.Insert ;

This inserts a blank record and makes it current so it will show
initialized values in all attached database fields.

Quote
>   Form4.DBEdit2.SetFocus;
>   Form4.DBEdit3.SetFocus;
>   Form4.DBEdit4.SetFocus;
>   Form4.DBEdit5.SetFocus;

These statements have nothing to do with filling the fields; they set the
focus in the user interface to a field (the hairline cursor appears in the
field you set focus to).

Quote
> //  Form4.DBNavigator1.BtnClick(nbPost); // post entry

Instead code Table1.Post ; But remember, the Table component will help you
by posting as soon as you move off the record by Table1.Next or
Table1.Insert and the like.

Code all your database acces thru table and query components. The DBEdit
fields are just for showing and updating.

I understand from your coding that DBEdit4 fills a date/timestamp. When
this is stored in the database it will be converted to a internal format
which may look like a strange number, depending on the database. Internally
Delphi also stores timestamp fields in such a strange format: the number of
seconds since midnight 1-1-1900 if I am not mistaking.

As a last tip: do not crosspost (posting to more than one newsgroup) and do
not ask to get a reply by mail, it is considered not done.

Good luck.

--
Met vriendelijke groet,

Menno

Other Threads