Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCmd.OpenView with SQL 2005

Status
Not open for further replies.

thromada

MIS
May 10, 2004
30
US
Hi all,

Summary: The problem is the sort order in a view created from within Access 2003 to a SQL 2000 backend database does not sort properly on a SQL 2005 backend database.

Detail: I have an Access 2003 app that uses a connection to a SQL 2000 backend. Some views were made with the query designer in Access 2003. As you know in the designer you choose the fields you want to show, choose a sort order, it creates the SQL code, and you save the query. Since the app is a project with a connection to a database, it saves the query as a “View”. One of the forms in the app has a combo box with a list of view names. When you choose a view name, it parses it into a variable and runs the command “DoCmd.OpenView <viewname>, acViewNormal, acReadOnly”. This opens the view in the pre-sorted order that the view was saved with. It works OK and when you’re done with the view you just close the window. Now I'm testing this all on a SQL 2005 backend. The problem is the sort order that the view was saved with is not working. I’ve been reading that views in SQL 2005 don’t honor the ORDER BY clause like SQL 2000 did. I’ve tried deleting and recreating the view in SQL 2005 Studio Express and in Access 2007, but the sort never stays. All that’s available are the designers in Studio Express and Access 2007. You choose the table, choose the fields you want to show, and choose a sort order, it creates the SQL code, and you save the query (view). Even if you open the view here it’s not sorted right. But if you run the view while in the designer, it sorts OK. What’s needed is a saved view that shows the records sorted properly when you open it. How can you create a view that will display the sorted records properly when opening the view?
Thanks much,
Tom.
 
I ended up making a form with a subform that has the fields displayed from a query in the Data Source. Sad, because it was a lot quicker to create a view and then just open it. But if anybody knows how to make the view work, please let us know.
 
Did you try referencing the view fields within your query (rather than the table fields)?

(As you pointed out, views ignore order by clauses.)

Greg
People demand freedom of speech as a compensation for the freedom of thought which they seldom use. Kierkegaard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top