> ## Content Index
> Fetch the complete content index at: https://nolongerset.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# OpenReport Shows Wrong Data
- URL: https://nolongerset.com/openreport-shows-wrong-data/
- Published: 2021-03-13T03:37:08.000Z
- Updated: 2026-05-08T13:05:57.000Z
- Description: Calling DoCmd.OpenReport on a report that's already open will not update the filtering on the report. You have to close it first.
- Author: Mike Wolfe
- Tags: Reports, #Import 2026-05-20 02:59

There are several [things that annoy me](https://nolongerset.com/report-annoyances/) about the default behavior of **DoCmd.OpenReport**. To address these annoyances, I built a replacement function that I named **PreviewReport()**.

In this series of articles, I will take you through the evolution of this function as I address each of my frustrations.

## Part 2: Wrong Data

If you call OpenReport on a report that's already open, Access doesn't apply the new criteria to the report. Instead, it simply sets focus to the already open report. 

In the example below, I'm using the Northwind database to open Invoice #30 followed by Invoice #31\. However, since I didn't close the report before calling it with the new criteria, Access shows Invoice #30 even when I call the method with `"[Order ID]=31"`.

```vba
DoCmd.OpenReport "Invoice", acViewPreview, , "[Order ID]=30"
DoCmd.OpenReport "Invoice", acViewPreview, , "[Order ID]=31"
```

If the report is already open, the new criteria is not applied.

![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2021/03/Invoice_30-3.png)

![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2021/03/Invoice_30-3-1.png)

### Workaround: Close the report before using new criteria

Here's the same example as above, except this time I'm closing the report before calling it with the new Where condition. Now it works the way we want.

```vba
DoCmd.OpenReport "Invoice", acViewPreview, , "[Order ID]=30"
DoCmd.Close acReport, "Invoice"
DoCmd.OpenReport "Invoice", acViewPreview, , "[Order ID]=31"
```

![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2021/03/Invoice_30-2.png)

![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2021/03/Invoice_31-1.png)

## PreviewReport() Evolution

To incorporate my workaround for this behavior, I first check to see if the report I'm trying to open has already been opened. To do this, I use my **[ReportIsOpen()](https://nolongerset.com/why-so-lazy-access/)** convenience function.

Here's the next step forward in the evolution of the PreviewReport() function, which now addresses two of my five [peeves](https://nolongerset.com/report-annoyances/).

```vba
Function PreviewReport(RptName As String, Optional Where As String = "")
    If ReportIsOpen(RptName) Then DoCmd.Close acReport, RptName
    DoCmd.OpenReport RptName, acViewPreview, , Where
End Function

'source: https://nolongerset.com/why-so-lazy-access/
Function ReportIsOpen(RptName As String) As Boolean
    ReportIsOpen = (SysCmd(acSysCmdGetObjectState, acReport, RptName) <> 0)
End Function
```

*Image by [Goumbik](https://pixabay.com/users/goumbik-3752482/?utm%5Fsource=link-attribution&utm%5Fmedium=referral&utm%5Fcampaign=image&utm%5Fcontent=2785979) from [Pixabay](https://pixabay.com/?utm%5Fsource=link-attribution&utm%5Fmedium=referral&utm%5Fcampaign=image&utm%5Fcontent=2785979)*