Make queries read only?

C

Chuck Arbogast

Hello,
I am using code to create a query based on user inputs. What I want to do
is create this as a read only query. I want to use code to do this.

Any help is appreciated,
Chuck
 
A

Allen Browne

Try setting the query's RecordsetType property to Snapshot:

CurrentDb().QueryDefs("Query1").Properties("RecordsetType") = 2
 
J

John Vinson

Hello,
I am using code to create a query based on user inputs. What I want to do
is create this as a read only query. I want to use code to do this.

One sneaky but effective way is to set the Unique Values property of
the query to True (include the primary key or some other unique field
in order to see all records).

If you're opening the query in code, use dbSnapshot instead of
dbDynaset.

John W. Vinson[MVP]
 
C

Chuck Arbogast

Thanks for all the help but I figured out my own question. For anyone
interested here is the line of code that made this happen:

DoCmd.OpenQuery "QueryName", , acReadOnly
 
Top