PDA

View Full Version : Solved: Ascending Query not working



Trevor
03-13-2008, 09:15 PM
I am using this query onclose event of form to order calllu table .Calltype ascending , it doesn't produce an error message, I try it by entring data that would cause it to have to be moved from the location it was enterd in to a higher location in the table and when I close and reopen the table nothing has moved .


Dim strsql As String

strsql = "SELECT CallLU.CallType" _
& "From CallLU" _
& "ORDER BY CallLU.CallType;"
End sub

orange
03-14-2008, 05:33 AM
I am using this query onclose event of form to order calllu table .Calltype ascending , it doesn't produce an error message, I try it by entring data that would cause it to have to be moved from the location it was enterd in to a higher location in the table and when I close and reopen the table nothing has moved .


Dim strsql As String

strsql = "SELECT CallLU.CallType" _
& "From CallLU" _
& "ORDER BY CallLU.CallType;"
End sub


This is SQL for a query. It does not get executed unless you do something like

db.execute ...
or
docmd.openquery ....

Trevor
03-14-2008, 12:33 PM
would that be?

Dim strsql as string
strsql = "SELECT CallLU.CallType" _
& "From CallLU" _
& "ORDER BY CallLU.CallType;"
docmd.openquery "qryname"
end sub

Trevor
03-14-2008, 06:33 PM
DoCmd.RunSQL "SELECT CallLU.CallType From CallLU ORDER BY CallLU.CallType;"

I get an error stating that access riquire an argument consisting of an SQL statment

orange
03-14-2008, 10:17 PM
DoCmd.RunSQL "SELECT CallLU.CallType From CallLU ORDER BY CallLU.CallType;"
I get an error stating that access riquire an argument consisting of an SQL statment

Sorry Trevor, I was wrong with the db.execute or docmd.runsql

These will not work with a SELECT query. They only work with Action queries.

You could open the SQL as a recordset depending on what you're going to do with the data.

Trevor
03-14-2008, 10:30 PM
ok, think i'll try it in the morning,
FYI, what Im doing, is I have a datasheet form that emulate the physical table to have more controle over the end user when editing, and I want to order the table in ascending order after the update/change information.
I may need to add a timer to tiger this to work correctly

Trevor
03-15-2008, 04:30 PM
I discoverd if you go into the table in design view and right click and select properties, on the order by you would enter Table.columnName and save changes and the table always order itself by that reference