Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / March 2006

Tip: Looking for answers? Try searching our database.

How to write query for sorting data in table using VBA?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
March - 29 Mar 2006 21:48 GMT
I need help with VBA.
I create a temp table to keep data for tranfering file from Excel. Sometimes
I have found unsorted data in the table, but always sorted.
All above I use VBA, so how can I sort data in the table? I need to use this
temp table to be a source table, before I transfer the data by using INSERT
query to other tables in the same access file.
Vincent Johns - 30 Mar 2006 00:15 GMT
Some of what you say seems inconsistent (for example, "I have found
unsorted data" doesn't match "always sorted"), but if I understand you
correctly, you don't need to use VBA.  Just define a Query based on your
linked Table.  For example, if the linked Table is [YourTable], you
could use

  SELECT YourTable.*
  FROM YourTable
  ORDER BY YourTable.ImportantField;

and use this Query as your dataset, instead of the Table.  You won't be
able to edit the results, but otherwise it will act a lot like a sorted
Table.

  -- Vincent Johns <vjonhs@alumni.caltech.edu>
  Please feel free to quote anything I say here.

> I need help with VBA.
> I create a temp table to keep data for tranfering file from Excel. Sometimes
> I have found unsorted data in the table, but always sorted.
> All above I use VBA, so how can I sort data in the table? I need to use this
> temp table to be a source table, before I transfer the data by using INSERT
> query to other tables in the same access file.
John Vinson - 30 Mar 2006 00:46 GMT
>I need help with VBA.
>I create a temp table to keep data for tranfering file from Excel. Sometimes
>I have found unsorted data in the table, but always sorted.
>All above I use VBA, so how can I sort data in the table? I need to use this
>temp table to be a source table, before I transfer the data by using INSERT
>query to other tables in the same access file.

You don't sort data in Tables. A Table should be viewed as an
unordered "bucket" of data.

You can use a Query with an Order By clause (select Ascending or
Descending on the sort row in the query grid, if you're using the grid
rather than the SQL window). That Query can then be used for reports,
forms, export to Excel, or whatever - it is not necessary to do
anything to the Table since you can do it all using the Query.

                 John W. Vinson[MVP]    
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.