SQL won't work (1 Viewer)

rschultz

Registered User.
Local time
Today, 21:19
Joined
Apr 25, 2001
Messages
96
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

Super Moderator
Staff member
Local time
Today, 16:19
Joined
Feb 19, 2002
Messages
43,385
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

Registered User.
Local time
Today, 21:19
Joined
Apr 25, 2001
Messages
96
>>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.
 

Users who are viewing this thread

Top Bottom