Components for Delphi and C++ Builder.

Go to Russian forum
Go to EhLib.com
It is currently 27 Apr 2024, 15:33

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: 25 Feb 2016, 11:43 
Offline

Joined: 12 Jul 2013, 22:21
Posts: 19
procedure TDFM_Conciliacao.CalcularSaldo;
var
qsaldo : Currency;
qDia : TDateTime;
AtualRec : TBookmark;
begin
// Exclui saldos anteriores...
AtualRec := MTLanca.GetBookmark;
MTLanca.DisableControls;
MTLanca.Filtered := False;
MTLanca.First;
while not MTLanca.Eof do
begin
if MTLancaStatus.Value = 4 then
MTLanca.Delete
else
MTLanca.Next;
end;
MTLanca.GotoBookmark(AtualRec); <== ERROR Rec Not Found (record has deleted by user)


Problem:

I know, I can't delete record...

but after that, DBgrideh paint/draw and Memtableeh edit/post doesn't work well anymore

Thanks


Top
 Profile  
 
PostPosted: 26 Feb 2016, 12:07 
Offline

Joined: 26 Jan 2016, 09:46
Posts: 56
Hi,

You used

Code:
MTLanca.DisableControls;


But i don't see
Code:
MTLanca.EnableControls;
before
Code:
MTLanca.GotoBookmark(AtualRec);


That's why
Quote:
DBgrideh paint/draw and Memtableeh edit/post doesn't work well anymore


Top
 Profile  
 
PostPosted: 26 Feb 2016, 16:54 
Offline

Joined: 12 Jul 2013, 22:21
Posts: 19
Hi


Yes, I used MTLanca.EnableControls; some lines under.

but the ERROR cause EXIT of procedure...

that's it.


Thanks


Top
 Profile  
 
PostPosted: 26 Feb 2016, 17:40 
Offline

Joined: 09 Feb 2012, 17:05
Posts: 124
You must do

Code:
MTLanca.DisableControls;
Try
  ...
  MTLanca.GotoBookmark(AtualRec); <== ERROR Rec Not Found (record has deleted by user)
... 
Finally
  MTLanca.EnableControls; <== You must always do that
End;


Top
 Profile  
 
PostPosted: 29 Feb 2016, 08:54 
Offline

Joined: 08 May 2014, 18:06
Posts: 663
Hello

You can use
Code:
function TDataSet.BookmarkValid(Bookmark: TBookmark): Boolean;

to check if Bookmark is Valid

_________________
Best regards
EhLib Support Team


Top
 Profile  
 
PostPosted: 08 Mar 2016, 17:21 
Offline

Joined: 08 Feb 2016, 01:27
Posts: 26
try this code
Code:
MTLanca.Refresh;
if MTLanca.BookmarkValid(AtualRec) then
MTLanca.GotoBookmark(AtualRec);


and you can use MTLanca.RecNo like this

Code:
procedure TDFM_Conciliacao.CalcularSaldo;
var
qsaldo : Currency;
qDia : TDateTime;
AtualRec : Integer;
begin
// Check if table is empty then Exit.
If MTLanca.IsEmpty then
begin
ShowMessage('Table is Empty');
Exit;
end;
// Exclui saldos anteriores...
AtualRec := MTLanca.RecNo;
MTLanca.DisableControls;
MTLanca.Filtered := False;
MTLanca.First;
while not MTLanca.Eof do
begin
if MTLancaStatus.Value = 4 then
MTLanca.Delete;
MTLanca.Next;
end;
MTLanca.Refrech;
if AtualRec < MTLanca.RecordCount then
MTLanca.RecNo := AtualRec
else MTLanca.Last;


Note: you don't need to use ELSE if you delete record or not you need to move to next record to check it.
I hope this will help you.. feel free to ask if you need more help.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 83 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group