Board index » delphi » Novice has questions

Novice has questions

Hello, and thanks to those who have helped with pervious questions.

I have a form that has a TDBEdit (and several other data aware
components) component.  The component is linked to a field in a
paradox table.  When a user wants to add a new record he/she simply
pushes an add button so that the current mode is set to add and the
table is set to append.  The data entry components are initially
disabled until the add button is pushed.

1.  Is it possible to copy the current date into the TDBEdit component
when the user hits the add button?  I want the current date to be
visible but not added to the record field until a save button (gives
the user the option to cancel) is pushed.  The save button is simply a
table.post

Actually, I got the first part  of this to work with DBEditBox.Text :=
DateToStr (Now);
the date is visible in the DBEdit Box, but is not added to the date
field in the table upon saving the record   : (

2. If this method of automatic date entry is possible and a user
modifies a record at some later date, the date will again be set to
the current date.  This is not necessarily what I want.  I would like
the user to be aware that a change is about to be made and would like
to give the option of changing or not.  Is this possible?

Sorry the above is so long winded, but I am still learning.

Thanks in advance for any assistance.

William Sutton
(Carbon Doctor)

 

Re:Novice has questions


In <31cff64f.2190...@usenet.interramp.com> pp001...@pop3.interramp.com

Quote
(wrsutton) writes:

>Hello, and thanks to those who have helped with pervious questions.

>I have a form that has a TDBEdit (and several other data aware
>components) component.  The component is linked to a field in a
>paradox table.  When a user wants to add a new record he/she simply
>pushes an add button so that the current mode is set to add and the
>table is set to append.  The data entry components are initially
>disabled until the add button is pushed.

>1.  Is it possible to copy the current date into the TDBEdit component
>when the user hits the add button?  I want the current date to be
>visible but not added to the record field until a save button (gives
>the user the option to cancel) is pushed.  The save button is simply a
>table.post

>Actually, I got the first part  of this to work with DBEditBox.Text :=
>DateToStr (Now);
>the date is visible in the DBEdit Box, but is not added to the date
>field in the table upon saving the record   : (

The problenm is that the text vanishes when you enter that edit box.
Toavoid this just put your line of code in the on enter event of the
edit box or in the on exit event of the edit box just before the date
edit box.  It will be there when you post.  I just tested it.

Quote

>2. If this method of automatic date entry is possible and a user
>modifies a record at some later date, the date will again be set to
>the current date.  This is not necessarily what I want.  I would like
>the user to be aware that a change is about to be made and would like
>to give the option of changing or not.  Is this possible?

If you follow the above code you will not have any problem on editing
the record.  

- Show quoted text -

Quote

>Sorry the above is so long winded, but I am still learning.

>Thanks in advance for any assistance.

>William Sutton
>(Carbon Doctor)

Re:Novice has questions


Quote
wrsutton wrote:

> Hello, and thanks to those who have helped with pervious questions.

> I have a form that has a TDBEdit (and several other data aware
> components) component.  The component is linked to a field in a
> paradox table.  When a user wants to add a new record he/she simply
> pushes an add button so that the current mode is set to add and the
> table is set to append.  The data entry components are initially
> disabled until the add button is pushed.

> 1.  Is it possible to copy the current date into the TDBEdit component
> when the user hits the add button?  I want the current date to be
> visible but not added to the record field until a save button (gives
> the user the option to cancel) is pushed.  The save button is simply a
> table.post

> Actually, I got the first part  of this to work with DBEditBox.Text :=
> DateToStr (Now);
> the date is visible in the DBEdit Box, but is not added to the date
> field in the table upon saving the record   : (

What you want to do here is assign the value to the _field_ object like:

DBEditBox.Field.AsString := DateToStr(Now);

Quote
> 2. If this method of automatic date entry is possible and a user
> modifies a record at some later date, the date will again be set to
> the current date.  This is not necessarily what I want.  I would like
> the user to be aware that a change is about to be made and would like
> to give the option of changing or not.  Is this possible?

Sure, try:

if DBEditBox.Text <> '' then
begin
  ...ask the user if it's ok to update the date to today
  ...if yes, assign the date
end;

Quote

> Sorry the above is so long winded, but I am still learning.

No problem.

Quote
> Thanks in advance for any assistance.

> William Sutton
> (Carbon Doctor)

HTH,

Mark

Other Threads