MS Access Crashes on “SELECT ?” Query

I found another way to force MS Access to crash to desktop, and it’s shockingly simple.

Sub SQLTest()
    Dim Query As ADODB.Command
    Set Query = New ADODB.Command
    With Query
        .ActiveConnection = CurrentProject.Connection
        .CommandText = "SELECT ?"
        .Parameters.Append .CreateParameter(, adChar, , 1, "a")
        .Execute
    End With
End Sub
Continue reading MS Access Crashes on “SELECT ?” Query

MS Access Crashes on TreeView.Nodes.Clear

I found a specific situation where MS Access always crashes to desktop.  Here are the ingredients:

  1. A bound Form with a Microsoft TreeView Control, version 6.0.
  2. Form’s “Allow Additions” property set to “No”
  3. TreeView populated using the Form_Current() event.
  4. Prior to populating the TreeView, calling .Nodes.Clear on the TreeView object.
  5. To set up the crash, filter the form to an empty recordset.
  6. Click on the Home ribbon and the Toggle Filter button.

Download Testcase File: treeview-testcase.accdb

Workaround

In the Form_Current() event, add a DoEvents command immediately before Nodes.Clear.

Set MyTree = Me.TreeView0.Object
DoEvents
MyTree.Nodes.Clear

InStr Performance for VBA

I solved a mysterious bottleneck last night while working with large string values in MS Access. My VBA code was reading a file to a string variable, checking several values near the beginning of the string, and then manipulating and saving the string to the database.

Oddly, one of the slowest parts of my code was the several InStr calls that were only checking the first few hundred bytes of the string. I could alleviate part of the problem by copying the beginning of my file to a shorter string value, but in so doing I also noticed unexpected results from the InStr return value.

Continue reading InStr Performance for VBA

External Link Security Broken in Excel

Excel Security Warning About Linked Workbooks

After linking two local Excel files by a simple reference to a cell in another workbook, I began seeing an ominous error:

SECURITY WARNING  Links to external sources could be unsafe. If you trust the links, click Update. Click for more details.

This behavior was observed in version 1907 of Excel from the Office 365 software package.

Warnings of this nature should be taken seriously.  In this case, however, the message has been seriously mislabeled.  Clicking into the details brings up an ancient Help page for Excel 2007.  Searching for similar situations online brings up some misleading instructions.

If you are experiencing the situation described above, continue reading below for a simple workaround and more background information.

Continue reading External Link Security Broken in Excel

Virus Infected Email

Screenshot of a fake Office 365 error message.
Danger! Do Not Touch!

If you see a Word document containing the following phrase, it is fake and should be deleted immediately:

This document created in online version of Microsoft Office Word

There is no such message ever issued by legitimate software.

Instructions included with the file asking the user to “Enable content” should raise red flags and serious concerns about the file’s origin.

A quick scan using an online virus checker confirmed this file is infected.  Be careful out there.