Options

File form not refreshing after ERASE

DenSterDenSter Member Posts: 8,304
I have a form that displays the files in a certain folder, and a command button that executes some code. After the code is executed, the file can be deleted, so I use the ERASE command. All works well, the code does its thing with the file, and the file itself gets deleted. I want the list of files to be refreshed, but even though I do a CurrForm.UPDATE, the deleted file just won't go away :-k

Does anybody have any tips for me? I don't care if I need to approach this a different way, but I need that list of files to refresh when I delete a file.

Thanks

Comments

  • Options
    fbfb Member Posts: 246
    There's some voodoo about resetting the filter on Path in order to refresh the list of files in the virtual File table, referenced here:

    http://www.mibuso.com/forum/viewtopic.php?t=1672

    I'm not sure how you would implement this in your form.... I'd begin with something like
    SavRec.COPY(Rec);
    Rec.RESET;
    Rec.COPY(SavRec);
    IF Rec.FIND('=><') THEN;
    CurrForm.UPDATE;
    
  • Options
    DenSterDenSter Member Posts: 8,304
    Brilliant!! \:D/

    That link gave me the information I needed. I ended up having to add a bogus path filter both in my OnOpenForm and at the end of the button code.

    So where I had this:
    [b]OnOpenForm[/b]
    File.SETFILTER(Path,'C:\My Folder'); // note that a "\" at the end will not work
    File.SETRANGE("Is a file",TRUE);
    
    [b]OnPush[/b]
    CurrForm.UPDATE;
    

    I changed it to:
    [b]OnOpenForm[/b]
    File.SETFILTER(Path,'C:');
    IF Rec.FIND('-') THEN;
    File.SETFILTER(Path,'C:\My Folder'); 
    
    [b]OnPush[/b]
    File.SETFILTER(Path,'C:');
    IF File.FIND('-') THEN;
    File.SETFILTER(Path,'C:\My Folder'); // no need for CurrForm.UPDATE
    
    and that works! Thanks a lot, that really helped me out =D>
  • Options
    RobertMoRobertMo Member Posts: 484
    An explanation could be that "virtual tables" are unaware of changes in the record-set on which they rely on. Delete of file is not managed through the record set, so there is no need to change the record set.

    You forced the change of record set by applying different filter and then reapplying previous one (again new one for record set).

    For regular tables also changes (modify, delete, insert) are managed through the same record-set, so it is aware that it needs to refresh.

    It would be interesting to explore and compare behavior of regular tables, when someone else deletes a record behind (e.g. in SQL QA). As far as I remember it also behaves strange.
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • Options
    eromeineromein Member Posts: 589
    Glad I could have been a bit off help (indirect) ;)
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • Options
    DenSterDenSter Member Posts: 8,304
    Emiel.... You Da Man!! =D>

    I was thinking along the same lines Robert, that's the only way it makes sense. The thing that gets me though is that Navision gives us a familiar way to interact with 'outside objects', but they don't follow through. The way I see it is that if they implement the file structure as a Navision table, they should also make it behave like a Navision table.

    This is not a knock on Navision, but it would have been nice to have this information in F1 help. I am happy to at least have the virtual file table, since it gives my customer a familiar interface.
  • Options
    RobertMoRobertMo Member Posts: 484
    DenSter wrote:
    ...they should also make it behave like a Navision table...
    You could hear from Navision: Boys, be glad that you have Virtual tables at all!
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • Options
    DenSterDenSter Member Posts: 8,304
    what's even scarier, is that I AM happy about that #-o
Sign In or Register to comment.