Microsoft Access can bring a deleted query back only if that query was never saved to the database, and even then only while the query window is still open or unclosed after the accidental deletion. If you closed the query after deleting its contents, closed the database afterwards, or removed the saved query object from the Navigation Pane, Access has no built-in undo history to restore it. The method that works depends on which of those two very different events occurred.

That distinction drives everything below. People use the word "delete" in Access for two unrelated actions. One is clearing the query definition while the Design View window is open, which you can sometimes reverse with a single undo. The other is removing a saved query object entirely, which requires a backup, an exported copy, or rebuilding the query from scratch. Before you hunt through menus for a Restore command that doesn't exist, check which situation you're in — it usually takes about ten seconds.

The first determination: did you delete the query's contents or the saved query object?

Open the Navigation Pane and look at your query list. If the query still appears there with its original name, you deleted its contents or its criteria, not the object, and your options are Undo, close-without-saving, or rebuilding inside the existing query. If the name is gone from the list, the object itself was deleted, and the undo path no longer applies.

Two quick checks settle this. First, does the query window still show undo arrows in the Quick Access Toolbar? Greyed-out undo means the change has already been committed to memory and the reversible window has passed. Second, did you see a confirmation prompt when the deletion happened? Access asks you to confirm object deletion from the Navigation Pane; it does not ask when you clear criteria inside Design View. A confirmation prompt is strong evidence you removed the object.

There's one more case worth naming: deletion of records that a query returns. That is data deletion, not query deletion, and it follows a completely different recovery path covered further down. Keep the three cases separate in your head — contents, object, data — because the fix for one does nothing for the others.

Undo a query change while the Design View window is still open

This is the only true one-keystroke recovery Access offers for a query definition, and it works in every modern version including Microsoft 365 and Access 2019/2021 because it relies on the standard Windows undo stack rather than a version-specific feature.

Prerequisites: the query must still be open in Design View in the same session, and you must not have closed the query window after the change.

1: Press Ctrl+Z once. Access reverses the most recent reversible edit, which may restore deleted criteria, a removed table, a deleted field, or a cleared expression, depending on what you did last. 2: Press Ctrl+Z repeatedly if you made several changes in sequence. The undo stack unwinds them one at a time. 3: Watch the query grid after each press. The restored element should reappear in the same row it occupied before, or the table returns to the upper pane with its join lines intact. 4: Save the query with Ctrl+S only after you've confirmed the restored logic returns the rows you expect.

Success check: switch to Datasheet View (the View button, or the datasheet icon) and compare the record count and visible fields against what you remember. If the count and columns match, the undo worked. If Datasheet View errors out with an unresolved reference, an undo restored a partial change — a field without its table, for example — and you should undo further or close without saving.

Failure handling: once undo arrows grey out, Ctrl+Z does nothing and no message appears. That silence is the signal to stop pressing keys and move to the close-without-saving route. Also note the undo stack belongs to the open window, not the database. Reopening a query starts a fresh stack, so undo will not reach changes made before you closed it.

Close without saving to discard accidental edits to a query

If you altered a saved query — deleted its criteria, changed its joins, removed output fields — and the window is still open, discarding the unsaved edits returns the query to its last saved state. This is how can i get my deleted query back in access resolves for the most common scenario: someone deleted their filter or a whole table from the query grid and panicked.

The actions in order:

1: Do not press Ctrl+S. Saving commits the damage. 2: Close the query window using the X, or press Ctrl+W. 3: When Access asks whether to save changes, choose No. 4: Reopen the query from the Navigation Pane.

Success check: the reopened query shows the original criteria and fields exactly as they were the last time you saved it. Compare against a known-good result, such as a count you recorded earlier.

One boundary matters here: this only rolls back to the last save. If you saved the damaged version at any point, closing won't help, and you're now in the rebuild or backup territory described below. Access does not keep automatic version history of a query definition the way some document editors keep file revisions.

Rebuild a deleted query from its SQL, if a copy survives anywhere

When the saved query object is gone, your fastest realistic recovery is a copy of its SQL statement. Access has no recycle bin and no built-in undo for deleted objects, but people routinely leave the SQL in places that outlive the object.

Check these locations before rebuilding by hand:

Possible copy location How to check What you can recover
SQL View of the deleted query, if any window still shows it Scroll the database window tabs The full statement, if the window was open and unsaved
An exported .sql or .txt file Search your project folder for the query name The statement text, importable by pasting into SQL View
A form or report's Record Source Open the object's property sheet, look at Record Source The exact SQL if the query was used there and pasted in
A macro or VBA procedure Search code for the query name or its SELECT text The sentence, recoverable by copying from the code editor
Documentation, email, or chat where you pasted the SQL Check recent messages and shared files A possibly complete statement
A copy of the database file with a date before deletion Locate .accdb copies in file history, cloud version history, or backup media The whole query object, restorable

To rebuild from a statement:

1: Create a new query in Design View, then switch to SQL View without adding tables. 2: Paste the recovered SELECT statement. 3: Run it with the Run button and confirm the record count matches what the original returned. 4: Switch to Design View, then save with Ctrl+S and give it the original name.

Success check: the rebuilt query appears in the Navigation Pane under its old name and returns the same number of records as documented. Failure handling: "The SELECT statement includes a reserved word or an argument name that is misspelled" almost always means an object it references was renamed or deleted since the SQL was copied. Fix the object names in the FROM and JOIN clauses before resaving. Also check whether a newer table name replaced the old one, since Access renames don't always propagate into saved query strings.

If no copy exists anywhere, rebuilding by hand is the remaining path, and the next sections make that faster.

Restore the query from a backup or a file version copy

A backup restores the query object and its logic exactly, which beats rebuilding whenever one exists. This is the best-case recovery for "I deleted a saved query and it's gone from every list."

Steps, in order:

1: Locate the most recent copy of the database file before the deletion. Standard locations include OneDrive or SharePoint version history, Windows File History, a nightly network backup, or the previous-day copy you emailed yourself. Confirm the copy is the same .accdb file, not a .laccdb lock file. 2: Copy the backup to a separate folder first. Never work inside the only copy. 3: Open the backup copy in Access. 4: Navigate to Queries, right-click the query you need, and choose Copy. 5: Switch to your current database, right-click the Queries group in the Navigation Pane, and choose Paste. 6: Confirm the pasted query appears and runs.

Success check: open the pasted query in Datasheet View and confirm the record count and fields. A paste that shows "Unrecognized database format" or a broken reference means the backup came from a different Access version or the source tables moved — relink the tables before running the query.

Cost comparison, with assumed inputs: rebuilding a 15-table join query from memory can take an hour or more of careful re-testing, while paste-from-backup takes a few minutes. If a backup copy exists within a day or two of the deletion, restoring is almost always the lower-risk choice because it preserves the original tested logic rather than a remembered approximation. The trade-off is that a backup restores only what it contains — a query that depended on tables renamed since the backup will need its references updated after the paste.

Rebuild the query by hand in Design View

With no copy and no backup, you rebuild it. That's the honest answer, and Access makes it manageable if you work from the result rather than from memory alone.

Prerequisites: know the tables or source queries the original used, and know roughly what its output looked like — the fields it showed, the filters it applied.

1: Choose Create, then Query Design. The Add Tables pane opens. 2: Add each source table or query. Drag fields from the field list onto the grid in the order the old query showed them. 3: Recreate the criteria in the Criteria row, one condition per column. For example, put a date range on an OrderDate column and a region value on a Region column. 4: Rebuild joins. If the original required a specific join type, open the relationship line properties by double-clicking the line and set the join property. Access's default inner join excludes unmatched rows; a query that used outer joins will look wrong until you set them. 5: Enter any calculated expressions in a blank column, matching the original field aliases exactly so downstream reports don't break. 6: Add sorting and any Group By settings in the Total row if the old query aggregated. 7: Run in Datasheet View. Compare the record count and saw the first few rows against a source of truth, such as a spreadsheet total from the same month. 8: Save with Ctrl+S under the original name and run a form or report that depends on it to confirm downstream objects still function.

Success check: the record count matches your documented total, and dependent forms and reports open without "The Microsoft Access database engine cannot find the input table or query" errors. Failure handling: if counts are too high, a missing criterion is the likeliest cause. If counts are too low, check join types and criteria for conflicting AND/OR logic, and verify the criteria weren't placed on the wrong field row so they apply to a table where you meant to filter a related one.

A practical shortcut: rebuild the same logic as a totals query first to confirm the row count matches, then remove the grouping to return detail rows. Matching the count in aggregate form takes less clicking than diagnosing a discrepancy in a wide multi-table result.

If the deletion was records rather than the query itself

A different problem deserves its own handling: you ran a delete query or manually deleted rows that a query returned. Deleting records is permanent inside a live database the moment you confirm the action — Access has no rollback for row deletion after the fact, and later queries will simply return fewer rows.

The supported recovery path is restore from backup only. Open the most recent copy made before the deletion, then either copy the deleted rows into your live table with an append query or import the whole table from the backup into the current file, then reconcile any changes made since the backup. If the table has relationships to other tables, check referential integrity after importing; orphaned foreign keys are the usual symptom, appearing as #Error values in lookups.

Do not attempt this with a compact-and-repair pass or a linked-table relink. Neither restores deleted rows, and repairing a database won't help. The decision rule: if the data exists in a backup, restore it; if it doesn't, treat the loss as final and rebuild the rows from the original source system or paper records.

Set up automatic protection so the next deletion takes five minutes

Access can't undo a saved-object deletion, so the only durable protection is a system that keeps copies outside the database. The good news is that these settings survive version changes because they're file-level features, not Access menu options. Three practical measures, each with a trade-off:

Turn on AutoRecover interval. In Access Options, under Current Database, set the AutoRecover interval in minutes (defaults vary by version; confirm on your version's Options screen). AutoRecover helps with unsaved work crashing mid-edit, but it doesn't restore deliberately deleted saved objects. Treat it as crash protection only. Keep Access files inside OneDrive or SharePoint. Version history there can recover the whole file to a prior point, which restores deleted queries — but it also rolls back every other change made after that point. Export or copy the needed query out, then bring it back into the current file. Save a copy of the database before major edits. File, Save As, or a copy-paste of the file with a dated name takes seconds. For a work database, a nightly copy kept for a week costs little storage and settles most recovery questions without a technical route.

A worked assumption: a 50 MB .accdb (rough for a few thousand records with queries and forms) kept as seven daily copies uses under 400 MB. That's trivial storage for the insurance, though many real databases measure in tens or hundreds of MB, so check your file size before deciding how many copies to keep.

Questions that come up when a query disappears

Is there a Recycle Bin or Undo for deleted Access objects? No. Access does not provide an object recycle bin, and the Ctrl+Z stack clears when a window closes. Treat saved-object deletion as irreversible inside the file.

Can I see who deleted the query? Access records no deletion audit trail by default. If your file is on a network share or SharePoint, file-level access logs may show who opened or changed the file, but they do not identify which object was removed.

What if the query references an external database? Rebuilding the logic is straightforward, but confirm the linked tables still point to a reachable file before trusting the result. The query can be identical to the original and still fail because the link path broke, producing "The Microsoft Access database engine cannot open or write to the file" rather than a query-level error.

Can a decompiled or repaired database recover the query? Compact and Repair fixes corruption, not intentional deletion. It won't bring back a deliberately removed query.

The general limits here are educational, not IT-department advice. Recuperation of a truly deleted Access object cannot be promised by any in-product method, and if this is a regulated or business-critical database, involve whoever manages your backups before you experiment on the live file.