0
votes

I have a datawindow where users can edit data and then click a 'Save' button. I've coded the ItemChanged event on the datawindow to store the old and new values in instance variables so that they can be saved in the database for reference. If the user edits a field in the DW and doesn't tab out, ItemChanged does not get called. So if they enter the data and immediately click 'Save', the instance variables are not getting populated.

I'm calling AcceptText as the first thing in the 'Save' button, which is supposed to get all the entered data in the DW and call ItemChanged (according to PB help). But it's not. What's weird is that it appears to be going through all the code in the 'Save' button and THEN going through the code in the ItemChanged event.

Another weird thing is if I debug it and put a breakpoint in the ItemChanged event, when I click 'Save' it will go through the ItemChanged code, but it won't do the 'Save' button code. I have to click 'Save' a second time. That's ONLY when I debug and ONLY if I have a breakpoint there - when I run the application normally or in debug without a breakpoint, it calls ItemChanged after the Save button.

I've never seen anything like this, so I'd appreciate any advice you can offer. Thanks!

3
Is the accepttext failing? Good return code? Itemchanged would fire if they tab out but the accept text could be failing for some reason. Maybe try experimenting with editchanged which will fire with each character typed. Maybe someone put code in editchanged that messes with the buffers... unlikely but never know.Rich Bianco

3 Answers

0
votes

One of the first things I recommend in my PB Troubleshooting Guide when you see program flow that doesn't make sense is to regenerate everything, i.e. do a Full Build. That alone could resolve the issue. (Selective regens could resolve it as well, but if you're at all in doubt regarding dependencies or sequences required, I tend to fall back on system-directed gens.)

If you're wondering how you got into an instance of ItemChanged, first place I'd look is the call stack pane in the Debugger. If it was from an AcceptText() call, you should see that when you double-click the level above the current level. If there is no call stack above the ItemChanged, it could be from tabbing out of the column, pressing Enter, or maybe a posted AcceptText(). Sometimes a PBDEBUG trace, combined with the Trace page from PBL Peeper, can shed some light on how you got there when the debugger doesn't.

This is definitely weird behaviour, and I'm hoping the regen solves your problem.

Good luck,

Terry.

0
votes

Havent seen or heard anything like this in my 19 yrs of development with PB! Only thing can be if the object is corrupted and you can regenerate it as @Terry have said. You can also of course try to export the Windows, datawindows to a different PBL and try if it works there. About 10yrs ago I had a similar issue where the PBL file was corrupted and regenrating the objects was of no help. Accidentally, I tried to recreate a new app and it worked there. Slowly this became apparent with more tests. Hope you dont lose the same amount of time we wasted on such a silly issue!

0
votes

If a full rebuild as Terry recommends doesn't resolve your problem, try migrating the target. I'd go directly to migrate rather than trying another full rebuild. Think of migrate as the "No, really rebuild everything" command.