Recent

Author Topic: Sorting records after insert  (Read 1872 times)

daveinhull

  • Sr. Member
  • ****
  • Posts: 297
  • 1 divided by nothing must still be 1!
Sorting records after insert
« on: September 18, 2017, 11:08:46 pm »
Hi,

Just wondering if someone could help with what is probably a very simple issue.
I'm using the TDBNavigator to add a new record and it works OK except that the record is the first in the Form list until I exit and restart.
I was looking for some On Event which I could use once it has been added to do a query refresh, but the query after insert seems to go of when the new record becomes available rather than when I press the tick (accept) in the Navigator.

Any help or a reference to look at would be much appreciated.

Thanks
Dave
Version #:1.8.4 Date 2019-01-08 FPC Version: 3.0.4 and SVN Revision 57972 for x86_64-win64-win32/win64

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Sorting records after insert
« Reply #1 on: September 18, 2017, 11:23:30 pm »
use after post
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

daveinhull

  • Sr. Member
  • ****
  • Posts: 297
  • 1 divided by nothing must still be 1!
Re: Sorting records after insert
« Reply #2 on: September 19, 2017, 10:45:33 am »
Hi taazz,

Yes I'd thought of that but if I do something like .Refresh after post then it will refresh whenever I do an edit to a EditBox and this pushes the current record back to the start.
I suppose I could save the record position, .Refresh and then restore the record position, but was hoping there was something else I could do a bit neater.

Thanks
Version #:1.8.4 Date 2019-01-08 FPC Version: 3.0.4 and SVN Revision 57972 for x86_64-win64-win32/win64

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Sorting records after insert
« Reply #3 on: September 19, 2017, 11:19:45 am »
what you are describing is server side indices. If you want client side indices then in delphi you had to use a clientdataset and its index properties (eg indexfieldname). SqlQuery seems to be based on tbuffdataset which has the indexfieldnames property included try to use that instead. be forwarned I have never done that in lazarus so I'm not a good point of reference.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

 

TinyPortal © 2005-2018