Gustav Brock
Gustav at cactus.dk
Fri Jan 13 10:12:42 CST 2006
Hi Andy What a story and what a lesson. I've never liked the dot for bang. Even though the dot is needed for intellisense to work, I often change the dot back to a bang. You certainly deserve the weekend and a nice beer or two! Thanks for enlighten us. /gustav >>> andy at minstersystems.co.uk 13-01-2006 16:54 >>> Well at long last I've cracked what was causing my strange crashes under W2000. For the sake of the archives, and anyone else who encounters this nightmare, I will tell all. We all know that you can refer to controls on forms as form!ctl or form.ctl. We can argue about the rights and wrongs of the second of those but we know you can do it. This is not about that argument. What, though, if you have a field in a form's underlying recordsource but not on the form? If you referenced that you'd think that you must use the ! form wouldn't you, as there is no control? I would. But what if you inadvertently use the . form? What, in particular, if you pass the form as a parameter to a function and make that mistake inside the function (thereby giving the compiler no chance of picking it up as an error)? Well maybe nothing...but then again maybe programming havoc. W98 seems to be extremely tolerant of this mistake. It treats it as if you'd coded ! after all. You will be none the wiser about your slip-up. Moving the same MDB to W2000 or XP was a different story. What happened there was that once the offending line had been executed the system would inevitably crash, at some point, either with a non-specific "Msaccess.exe has generated errors and will be closed by Windows" error, or a GPF or a "Tried to write to memory location xyz and you're not flipping allowed to" error. But the 'beauty' of this was that it *never* crashed on the line which caused the errors, just at seemingly random points thereafter. So standard debugging methods were useless. As fast as I put traps in one part of the system it would crash somewhere else entirely. So I'd switch my attention to there, and it blazes through there without a hitch and a couple of minutes later GPFs somewhere else. I was tearing my hair out. In the end, and it's taken all week, I took a different approach. I said, if I quit this area of code after it's executed 1 line, do I get any crashes? Answer, no. If I allow it to go to the end do I get crashes, answer yes. So, if I quit the code half way through, do I get crashes? If yes the code before the half-way point is causing it, if no it's between half-way and the end. You get the picture. In that way I chopped and chopped and, a long, long time later, got down to the function and then the line that made the difference. Not, remember, that executing the line crashed, but that executing the line caused the system to crash somewhere else soon. And that's when I saw that whilst the surrounding lines were of the format frm!fld = rst!fld this one was frm.fld = rst!fld So I changed . to ! and lo and behold no more crashes. And I can only talk about A97, as I can't test my app on anything else, and I know it's not even a universal problem in A97 as I just tried to create a little MDB to demo the problem, and it fails to crash. So there's no consistency in any of this but there is a huge problem there somewhere, cos when it does hit it's a terror. It's perhaps the closest I've come in 30 years of programming to saying I can't solve this because it defies logic. But still, it's solved now, just in time for the week-end so I'll be having a big drink tonight. Thanks to all who responded to my plea earlier in the week. I was on the wrong track with DLL's, although I think I can be forgiven for thinking along those lines, and it was Shamil who urged me to focus on code. You were right as ever Shamil, although even you might be taken aback by a seemingly trivial coding error that 'works' itself but causes such collateral damage elsewhere. Have a good week-end all. I know I will. -- Andy Lacey http://www.minstersystems.co.uk