Can I sort a table in a macro?

G

Gary Schuldt

I want to sort a small table as one of the actions in a macro.

I want to sort on two fields.

The fields are created (ALTER . . . ADD) in a prior step.

I know it's better to sort using a query, but the Access table is being
created as input to another program.

Thanks.

Gary
 
K

Ken Snell

By procedure, do you mean VBA code? If yes, the answer is still no. You can
create a query that is ordered the way you want and then export the query's
contents to a text file and then use the text file as the input for your
other program.
 
G

Gary Schuldt

Ken,

yes, I meant VBA code.

OK, so the answer is still no . . . I get it now.

The downstream program is a label printer driver which reads a .mdb table
(Access 97 format) directly and maps the columns to a template you design.

I'll figure something out on how to get the output sorted. Maybe I'll just
display the table in datasheet view and have the user sort on the major
column and not deal with the secondary sort.

Thanks.

Gary
 
K

Ken Snell

Can your printer driver "read" a query as the table? Try it and see; it may
work for your needs.
 
G

Gary Schuldt

Don't really know how it works; the documentation says it reads an Access 97
compatible table in "mdb" format. Right now I'm exporting the table from
Access 2K into an Access 97 db whose only contents is that table, and the
printer-driving software (P-touch Editor) picks it up fine. I guess if I
can export the query the same way, and it's stored the same as a table, it
shouldn't be able to detect the difference!

Gary
 
K

Ken Snell

Exporting a query into a table should result the same as exporting a table
into a table. You should be able to do what you want. However, just a word
of caution....ACCESS does not necessarily store records in a table in the
same order that you export the records. So when your program retrieves them,
it's still possible for it to "see" them in a different order. You may be
able to help this if the table that the printer program is reading has a
primary value field (and that that is the only indexed field) that will, in
an ascending order, present the records in the desired order.

Good luck.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top