ms-access Remove Binary Data from Form


Example

Sometimes the crashes occur constantly in a single form or report, or occur only when printing. It is possible that the binary data within the form / report has become corrupt.

Save the Form / Report object as text There are two undocumented functions. Application.SaveAsText and Application.LoadFromText. You can use these functions to export the form/report definitions, clean up the definition, and then import it again.

  1. Make a backup of your database before proceeding
  2. Go to the VBA Immediate Window (Control + G)
  3. Type Application.SaveAsText acForm, "MyForm", CurrentProject.Path & "\MyForm.txt" (Replace MyForm with the name of the Form / Report. Use acReport if it is a corrupt report you are fixing)
  4. Rename the original form item (e.g. rename to MyForm.Bak) within the Database Window

Clean up the Form / Report Definitions file

  1. Open the exported file (e.g. MyForm.txt) in notepad

  2. Delete the "Checksum=" line (should be on line 3)

  3. Clear out binary data

    1. Identify the binary data blocks. Look through the file and you will see lines that start with "Parameter = Begin". Following those lines you will have lines of encoded binary data. Finally, the binary block will end with a line consisting only of "End". The Binary Data block includes the first line (with the Begin statement) and all lines up to and including the last line (with the End Statement).

      Note: All of these blocks should appear BEFORE your form control definitions

    2. Delete the binary data blocks for the following parameters:

      • NameMap
      • PrtMip
      • PrtDevMode
      • PrtDevNames
      • PrtDevModeW
      • PrtDevNamesW
  4. Look for other issues. While you have the file open, scroll through the rest of the file and look for anything that catches your eye, especially in the VBA module code at the bottom. You will be looking for anything that sticks out from the rest, and may be corruption.

  5. Save the file.

Load the form / report back into Access and Test

  1. Load the form back into Access.
    • In Access, go to the immediate window (Control + G)
    • Type Application.LoadFromText acForm, "MyForm", CurrentProject.Path & "\MyForm.txt"
    • Decompile / Compact Repair / Recompile (See the other example within the documentation)
    • Open the form / report to test. Hopefully everything is working now.
    • Delete the old corrupt form (e.g. MyForm.bak)

Prevent this corruption in the future

The most common cause of corrupt binary data within a report / form is when multiple computers / users use the same database client file instead of having their own separate copy. This is why each user should have their own client file on their desktop that they run.