Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 9 of 9 total
Thread check for edit mode
Tue, Jul 10 2007 11:30 AMPermanent Link

NM
Is there a way to test if a table/query is in edit mode?  ie.  if a user clicks a button, I want a function to run that checks if a table is in edit mode...if it is then a message
box appears warnining the user...if not then the user can continute.

Thanks
Tue, Jul 10 2007 11:54 AMPermanent Link

Dave Harrison
NM wrote:

> Is there a way to test if a table/query is in edit mode?  ie.  if a user clicks a button, I want a function to run that checks if a table is in edit mode...if it is then a message
> box appears warnining the user...if not then the user can continute.
>
> Thanks
>

if table1.state in [dsEdit, dsInsert] then
  Ok := mrYes = MessageDlg('Warning-You are in edit mode'+#13#10+'Do
you want to continue?', mtWarning, [mbYes,mbNo], 0)
else
  Ok := true;

if Ok then
  begin
    //Continue
  end;


Dave
Tue, Jul 10 2007 11:59 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

<< Is there a way to test if a table/query is in edit mode?  ie.  if a user
clicks a button, I want a function to run that checks if a table is in edit
mode...if it is then a message box appears warnining the user...if not then
the user can continute. >>

if (MyDBISAMTable.State in [dsInsert,dsEdit]) then

--
Tim Young
Elevate Software
www.elevatesoft.com

Tue, Jul 10 2007 2:08 PMPermanent Link

Jim Margarit
Tim Young [Elevate Software] wrote:
> << Is there a way to test if a table/query is in edit mode?  ie.  if a user
> clicks a button, I want a function to run that checks if a table is in edit
> mode...if it is then a message box appears warnining the user...if not then
> the user can continute. >>
>
> if (MyDBISAMTable.State in [dsInsert,dsEdit]) then
>

If you are wanting to warn a user that another user is editing that
record then you will want a different approach. If it is single user,
then this will work. I wasn't totally sure which was the case from your
post.

Jim
Tue, Jul 10 2007 2:15 PMPermanent Link

"Robert"

"Jim Margarit" <mail@drmargarit.com> wrote in message
news:8A92EE9C-670F-49E8-B222-86508933D626@news.elevatesoft.com...
>
> If you are wanting to warn a user that another user is editing that record
> then you will want a different approach. If it is single user, then this
> will work.

Even then, a single user could have the table in edit mode via another
tTable. You need to use pessimistic lock mode, though of course that has
other issues involved.

Robert

I wasn't totally sure which was the case from your
> post.
>
> Jim

Tue, Jul 10 2007 3:02 PMPermanent Link

NM
Jim Margarit <mail@drmargarit.com> wrote:

Tim Young [Elevate Software] wrote:
> << Is there a way to test if a table/query is in edit mode?  ie.  if a user
> clicks a button, I want a function to run that checks if a table is in edit
> mode...if it is then a message box appears warnining the user...if not then
> the user can continute. >>
>
> if (MyDBISAMTable.State in [dsInsert,dsEdit]) then
>

If you are wanting to warn a user that another user is editing that
record then you will want a different approach. If it is single user,
then this will work. I wasn't totally sure which was the case from your
post.

Jim


Yes, I want to warn a user that another user is editing the record...so how would I go about doing this then?

Thanks
Tue, Jul 10 2007 4:06 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com


<< Yes, I want to warn a user that another user is editing the record...so
how would I go about doing this then? >>

See here in the manual:

http://www.elevatesoft.com/dbisam4d7_updating_tables_query_results.htm

under "Editing an Existing Record".

--
Tim Young
Elevate Software
www.elevatesoft.com

Tue, Jul 10 2007 4:28 PMPermanent Link

NM
"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote:

> See here in the manual:
>
> http://www.elevatesoft.com/dbisam4d7_updating_tables_query_results.htm
>
>under "Editing an Existing Record".


Yes this looks like it is what I want.  However, when I try to implement the following code I get an 'undeclared identifier: DBISAM_RECLOCKFAILED' error:


procedure TMyForm.MyTableEditError(DataSet: TDataSet;
  E: EDatabaseError; var Action: TDataAction);
begin
  Action:=daAbort;
  if (E is EDBISAMEngineError) then
     begin
     if (EDBISAMEngineError(E).ErrorCode=DBISAM_RECLOCKFAILED) then
        begin
        if MessageDlg('The record you are trying to edit '+
                      'is currently locked, do you want to '+
                      'try to edit this record again?',
                       mtWarning,[mbYes,mbNo],0)=mrYes then
           Action:=daRetry;
        end
     else if (EDBISAMEngineError(E).ErrorCode=DBISAM_KEYORRECDELETED) then
        begin
        MessageDlg('The record you are trying to edit '+
                   'has been modified since it was last '+
                   'retrieved, the record will now be '+
                   'refreshed',mtWarning,[mbOk],0);
        DataSet.Refresh;
        Action:=daRetry;
        end
     else
        MessageDlg(E.Message,mtError,[mbOK],0);
     end
  else
     MessageDlg(E.Message,mtError,[mbOK],0);
end;
Tue, Jul 10 2007 6:45 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com


<< Yes this looks like it is what I want.  However, when I try to implement
the following code I get an 'undeclared identifier: DBISAM_RECLOCKFAILED'
error: >>

Be sure to include the dbisamcn unit in your USES clause.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image