rschultz
07-18-2001, 10:17 AM
I have the following SQL statement, but when I click the button it's on I get an error saying I need an SQL statement to use RunSQL. What's wrong with the SQL I have? How do I put the table in order byt that field?
Dim STRField As String
STRField = "SELECT * " & _
"FROM [APS Import Test] " & _
"ORDER BY [APS Import Test].[Serv Acct ];"
Docmd.RunSQL (STRField)
Pat Hartman
07-18-2001, 06:44 PM
RUNSQL is only used to exectute action queries.
Your question is confusing because you can't use a query to permanently reorder a table. In a relational database how a table is physically ordered has no bearing on anything unless the RDBMS you are using supports clustered indexes which Access does not. I need some context to help you more. For example, are you trying to view/update data via a form? If so you can create a query with an order by clause and use that as the recordsource for the form.
rschultz
07-19-2001, 06:08 AM
>>are you trying to view/update data via a form
no, I was trying to order the table by a field. I went into the table, clicked on the field title, then clicked on the down arrow icon up on the menu bar. When I'm through tweaking the table I imported from a spreadsheet, I import it into the main table and then delete the temporary table. I have to do that each month. Now, somehow, since I manually did that, each time I import the table from a spreadsheet it's in that order again so I guess I don't need to do it each time, but I don't knwo why that would be since it's a new table each time. I just thought if it could be done manually by clicking the icon I should be able to do it with code.