Computer Learning Zone CLZ Access Excel Word Windows

Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young.

-Henry Ford
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Captain's Log    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
The Heisenbug
Richard Rost 
           
19 days ago
I've been doing a little browser automation lately using the WebView (Edge) control in Microsoft Access. I've covered WebView before, but I haven't really gotten too deep into using it for full-blown website automation.

The goal is to automate some repetitive browser tasks without relying on SendKeys. Instead, Access can navigate to a page, look for specific HTML elements, click buttons, fill in fields, wait for things to appear, and generally interact with the page through JavaScript and the DOM.

One of the things I'm currently automating is downloading some information from YouTube, specifically my members list so new signups don't have to wait for me to manually download and import it every business day. I only need this particular process to succeed once a day, so I set up my database to periodically try it automatically. The interesting part is that the automation worked, but it wasn't particularly reliable.

I'd let it run overnight and find that most attempts failed. Maybe one out of every five or six attempts would actually succeed. Technically, that's good enough for what I need. If it tries several times a day and succeeds once, I'm happy. That's still better than having to remember to do it manually every day. But, of course, the programmer in me wanted to know why it was failing.

My suspicion was timing. Modern websites do a ton of stuff asynchronously. Just because you've clicked a button doesn't mean the next element you need is immediately ready. JavaScript might still be running, the page might still be updating, or an element might exist but not quite be ready to interact with yet. So I decided to add a ridiculous amount of logging.

For every step in my automation script, I started dumping everything into a status box: the action name, description, browser action, sort order, parameters, temporary values, and basically anything else that might help me figure out exactly where the process was failing. Then, if an error occurs, the database can email me the contents of that status box so I can see exactly what happened. And here's the funny part. After adding all that logging, I ran the automation again. It worked perfectly.

Of course it did.

There's actually a name for this kind of thing: a Heisenbug. It's a software bug that seems to change or disappear when you try to observe or debug it. The name is a play on the Heisenberg uncertainty principle from physics.

In my case, I have a pretty good theory about what's happening. My logging routine doesn't just write information to the screen. Updating the status box and processing DoEvents introduces a tiny amount of additional time between automation steps. It also gives Windows and the browser an opportunity to process messages. So instead of effectively doing this:

Click -> Check -> Click -> Check

I'm now doing something more like this:

Click -> Log Status -> DoEvents -> Check -> Log Status -> DoEvents -> Click

Those tiny delays may be giving the YouTube interface just enough time to finish whatever it's doing before Access moves on to the next step. In other words, I may have accidentally fixed the timing problem by adding the code that was supposed to help me find the timing problem. That's a Heisenbug.

I'm going to let the automation run overnight with all of the logging enabled and see what happens. If it suddenly becomes much more reliable, that'll be a pretty strong indication that timing was the problem all along. At that point, I can either add some deliberate waits at the appropriate places or simply leave the logging enabled. And honestly, I might just leave it. This isn't a time-critical process. If downloading one CSV file takes a few extra seconds, I couldn't care less. Reliability is much more important than shaving a couple of seconds off the process.

There's also a good lesson here if you're doing any kind of browser automation. Websites don't necessarily behave like traditional desktop applications. You can't always assume that because Step A finished, Step B is immediately ready. Sometimes you need to wait for a specific element, condition, or page state instead of just firing commands at the browser as fast as your code can execute them. And sometimes adding debugging code fixes the bug. Because programming likes to screw with you like that.

If you guys want to see more lessons on automating websites from Microsoft Access without using SendKeys, post a comment down below. I've been doing a lot more with WebView and JavaScript lately, and there's definitely plenty more we could cover.

LLAP
RR
Richard Rost OP  @Reply  
           
19 days ago

Donald Blackwell  @Reply  
       
19 days ago
Definitely interested in more work interaction with webview.
Darrin Harris  @Reply  
     
19 days ago
I'm very interested, I am in the process of finding better ways then sendkey.
I did find some problems when finding your links, that is CAPTCHA, some times it can take a longer then other times?
like you said some things the code needs to wait for and be able to deal with them :).
Kevin Yip  @Reply  
      
18 days ago
Another possibility is that the website prevents you from automated data retrievals by generating data only when manual user interaction is detected.  Some websites do that because they frown upon any sort of automated scraping, as they want actual users who can see their ads.  I have a movie database made with Access that used to be able to grab data from IMDb by web-scraping, but now it can't because IMDb prevents it.
Alex Hedley  @Reply  
           
18 days ago
Alex Hedley  @Reply  
           
18 days ago
Sam Domino  @Reply  
       
18 days ago
Richard I would definitely like to see more automation!  I've been able to automate getting info from web sites that don't require logging into them (using Excel and MCode), but I would like to take the next step.  I would like to automate logging into the web site, move around it, selected the proper file, download a CSV file, and then log out.

You built a Heisenbug compensator.  Scotty would be proud!  LOL!  LLAP!
Thomas Gonder  @Reply  
       
18 days ago
Heck, you can see that kind of things (sort of) in Access. Got a funny thing happening in VBA code? Add a Stop or debug in the offending part, and ding, ding, ding, the bug goes away. Until you remove the Stop. I've tried pauses, but no, it has to halt execution.
Alex Lewis  @Reply  
       
18 days ago
I, for one, would love to see more with WebView and web automation.

In terms of debugging, I’ve fixed bugs in my own database before without really knowing what I did to fix it. Just like Scotty, I too have been known to be a “miracle worker.” LOL
Alex Lewis  @Reply  
       
18 days ago

Bill Mark Langdell  @Reply  
      
18 days ago
I can think of many applications for this.  Wiould love to see more browser automation with Access VBA, WebView and Javascript.  ALL SYSTEMS GO ! (Except for the debugging waits/pauses of couorse LOL)  Thanx.
Add a Reply Upload an Image
Next Unseen

 
 
What's This?

 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 9/5/2026 1:17:09 PM. PLT: 1s