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

Change the order of columns in a table (VBA)

Status
Not open for further replies.

cyork

MIS
Apr 4, 2001
34
0
0
CA
How can I move a column to the first position of an existing table using VBA?

Thanks,

Chris
 
What are you trying to do?

The column positions in a table a just logical ordinal positions. Does it really matter where they sit?


I'd imagine it is for display purposes, so
In SQL statements, it depends on which order the fields are selected in.

For the actual table, open it in design view and move the fieldname to the position you want. Save the table and hey presto!

Best of luck cyork.
 
I am using the TOP statement to select X number of records based on a sorted column. The help says that the sorted column you are selecting from must be the first one in the table.
 
I just went through the help for the TOP and I don't see anything like that. The following code works, selecting the students with the top 25 grade point averages, no matter the order of the columns in the table design:
Code:
SELECT TOP 25
FirstName, LastName
FROM Students
WHERE GraduationYear = 1994
ORDER BY GradePointAverage DESC;
You are telling it the order you want to see the fields in your select statement and the order to get the data in with your ORDER BY clause. Terry M. Hoey
th3856@txmail.sbc.com
While I don't mind e-mail messages, please post all questions in these forums for the benefit of all members.
 
Nice one Terry. Sorry if I didn't make that clear in the previous message cyork.
 
This is what I was referring to in the help on TOP:

"Remarks

Typically, you use the TopValues property setting together with sorted fields. The field you want to display top values for should be the leftmost field that has the Sort box selected in the query design grid. An ascending sort returns the bottommost records, and a descending sort returns the topmost records. If you specify that a specific number of records be returned, all records with values that match the value in the last record are also returned."

I guess the order does not really matter thanks...

Chris

 
I think what it was trying toi say there is if you are doing the sort of a query with several fields, if you click to sort on multiple different fields, the leftmost sorted column will be the first sort, the second leftmost will be next, etc. You are right, it does matter a little. What you do, in a fresh query window, select the fields you want to sort on (in order) first and then the other fields after that, thus putting them on the left... Terry M. Hoey
th3856@txmail.sbc.com
While I don't mind e-mail messages, please post all questions in these forums for the benefit of all members.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top