view datasheet sort as a visual basic variable

selahlynch

Registered User.
Local time
Today, 03:06
Joined
Jan 3, 2010
Messages
63
I'm trying to improve my understanding of datasheets...

I have a query that I saved in my Access application. I can see its SQL as a variable in Visual Basic by typing the following into the immediate window:
Code:
? CurrentDb.QueryDefs("TestQry").SQL
SELECT Employees.EmpName, Employees.EmpNumber
FROM Employees;
Now I am viewing my query in Datasheet View. I use the GUI to sort by EmpName. After sorting, there is no change to the SQL property of the query definition. Is there a way I can see this sort stored in another Visual Basic variable?

**I am working with Access 2007
 
It is the OrderBy property of the Form.
 
How do I access the "Form". All I have is a query and I am viewing it in datasheet view.
 
You can see it in the Properties in design view of the form.

In VBA:
Me.Form.OrderBy
 
I do not have a Form! I have a query.

This is what I am confused about.
 
The UI Order By property of a query can be seen in the Properties window.

In VBA it is:
Code:
CurrentDb.QueryDefs("queryname").Properties("OrderBy")

It isn't available as a dotted property as in a form like I described earlier but only as an indexed property.

Manipulating the properties in a query is not as easy as on a form or report because queries are meant to be displayed in forms or reports. Users should never see naked queries or tables anyway.
 
Last edited:
Thanks a lot Galaxiom... I never would have found that on my own!

I hear what you say that users should not look at naked tables or queries... mainly I was just curious. I want to understand things well. It always pays off eventually.
 

Users who are viewing this thread

Back
Top Bottom