quentinxs
quentinxs

Reputation: 866

MS Access queries display incorrectly

I have an access database with a form that runs 6 queries based on inputted values. A coworker went in to edit a query and instead of displaying the full query, Access is displaying the following

SELECT * FROM table WHERE 1 <> 1

I’ve tried opening a backup copy on a different computer as well as running Compact & Repair to no avail. The form is still running correctly, however.

Running Access 2016 and files displayed fine yesterday afternoon.

Upvotes: 0

Views: 36

Answers (2)

Darren Bartrup-Cook
Darren Bartrup-Cook

Reputation: 19737

This doesn't solve the problem (sorry, not sure what's happened) but should let you retrieve the SQL if the query still runs as expected.

Erm... basically what @ErikvonAsmuth just suggested. :)

Public Sub Test()

    Dim db As DAO.Database
    Dim qdf As DAO.QueryDef

    Set db = CurrentDb
    Set qdf = db.QueryDefs("MyQueryName")

    Debug.Print qdf.SQL

End Sub

Upvotes: 0

Erik A
Erik A

Reputation: 32642

It's hard to say what happened without more details, but some queries can't be represented in design view. Editing such a query in design view trashes it.

Anyway, the query is lost. If you don't have a backup, you're out of luck. (Very rarely a temporary query still exists, you can iterate through the querydefs collection to view the SQL of all queries including temporary ones).

Upvotes: 1

Related Questions