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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Acc 2010: How to sort a newly created table from an Excel import

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
I have VBA code to import a spreadsheet into a table which will be new each month. so the table name is new. I don't see any Macro command in the Macros wizard to sort?
When the data comes in it sorts teh first column, but we want the second column sorted A-Z.
Is there a way to do this without having to click the column and manually sort it?
Any ideas?

TIA

DougP
 
Generally speaking there is no sort notion in a table.
Use the ORDER BY clause in a query to see the data sorted as you want.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
normaly I don't work with a tables. BUT the boss does and would like to see it sorted after my macro imports and then opens the table.


DougP
 
Why does the boss work directly with tables?
 
I agree with PHV. Give the boss a query that sorts the first two (or however many s/he may want) and just run the query. As noted, the notion of first/last/sort order is irrelevant in a relational database table. As implied - unless the boss understands databases fairly well (and the requirement for a sorted table would indicate otherwise), it's better to keep them out of the table. Alternatively, you might have the VBA code sort the spreadsheet and then import the data. I know Oracle would still not guarantee the order, but Access might (sorry, Access is not a database I have a lot of experience with, so I can only address this in general terms).
 
I agree with carp in agreeing with PHV.

Access tables have no actual sort order that means anything. If you want the data sorted, you can do so with a query. Also, in my experience, it's far better to have users edit data through a form rather than directly in the table. This allows you to set up rules to keep them from doing something unexpected. Again, based on my experience, they will do something unexpected.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top