473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to sort table with VBA

Public Sub test()

DoCmd.OpenTable ("OSM Table 1")

End Sub

Amazingly, I've gotten this far, now I am wondering how to sort the
database in ascending order according to field called [Meal Total] and
then select the first record. It's all got to be in VBA, can anyone
help?

Thanks

Jul 17 '06 #1
9 47785
"Troy" <Tr**********@gmail.comwrote in
news:11**********************@b28g2000cwb.googlegr oups.com:
Public Sub test()

DoCmd.OpenTable ("OSM Table 1")

End Sub

Amazingly, I've gotten this far, now I am wondering how to
sort the database in ascending order according to field called
[Meal Total] and then select the first record. It's all got
to be in VBA, can anyone help?

Thanks
You can't sort a table. You make a query on the table and use that
query instead of the table.
--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Jul 17 '06 #2
DFS
Troy wrote:
Public Sub test()

DoCmd.OpenTable ("OSM Table 1")

End Sub

Amazingly, I've gotten this far, now I am wondering how to sort the
database in ascending order according to field called [Meal Total] and
then select the first record. It's all got to be in VBA, can anyone
help?

Thanks
Do
You can mess around and do it like this:

DoCmd.OpenTable "Table1"
DoCmd.GoToControl "field name"
DoCmd.FindRecord "VALUE", acAnywhere, False, acSearchAll, True, acCurrent
DoCmd.RunCommand acCmdSortAscending
DoCmd.RunCommand acCmdSelectRecord
But like B Quintal says, you should probably just run and open a query on
the table.


Jul 17 '06 #3
You should not open tables.

You should use a form for data entry and a report for data review.

Either way, you use a query as the recordsource as you can then sort the
data in any way you want.
--

Terry Kreft
"Troy" <Tr**********@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
Public Sub test()

DoCmd.OpenTable ("OSM Table 1")

End Sub

Amazingly, I've gotten this far, now I am wondering how to sort the
database in ascending order according to field called [Meal Total] and
then select the first record. It's all got to be in VBA, can anyone
help?

Thanks

Jul 18 '06 #4
DFS
Terry Kreft wrote:
You should not open tables.
This is bogus advice, I think.

You should open tables if you need to or if you want to. There's certainly
no need to create a form and report for every table in your system, eg just
to edit a small lookup table (or even a large transaction table).
Especially if you "know" your data.
You should use a form for data entry and a report for data review.
Why? Though a well-defined form can give you more control and safety, it's
no panacea, and building good validation rules and proper data typing can
aid in entering data directly in tables.
Either way, you use a query as the recordsource as you can then sort
the data in any way you want.
Yes. Or you can filter and sort it pretty much any way you want if you open
the table directly.

"Troy" <Tr**********@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
>Public Sub test()

DoCmd.OpenTable ("OSM Table 1")

End Sub

Amazingly, I've gotten this far, now I am wondering how to sort the
database in ascending order according to field called [Meal Total]
and then select the first record. It's all got to be in VBA, can
anyone help?

Thanks

Jul 18 '06 #5
"Terry Kreft" <te*********@mps.co.ukwrote in
news:AY********************@karoo.co.uk:
You should not open tables.

You should use a form for data entry and a report for data review.

Either way, you use a query as the recordsource as you can then
sort the data in any way you want.
In a report, don't sort your underlying recordsource, but use the
report's grouping and sorting.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Jul 18 '06 #6
DFS wrote:
Terry Kreft wrote:
>You should not open tables.

This is bogus advice, I think.

You should open tables if you need to or if you want to. There's
certainly no need to create a form and report for every table in your
system, eg just to edit a small lookup table (or even a large
transaction table). Especially if you "know" your data.
The advice assumes that the user of a database is not the developer of the
database. No one would dispute that the developer can make entries into
utility tables and/or make administrative corrections to other data directly
in the tables.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Jul 18 '06 #7
David W. Fenton wrote:
In a report, don't sort your underlying recordsource, but use the
report's grouping and sorting.
That's my approach and I prefer to base reports on unordered queries to
cut back on the unnecessary processing I assume takes place with the
order by clause.

But I vaguely recall at some point wasn't/isn't there some report
property one can turn on to accept the sorting done by a query?

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Jul 18 '06 #8
The OP was talking about writing code to open the table.

This implies that they are writing an app for someone else to use.

Only an idiot or a grossly inexperienced developer would allow users direct
access to base tables.

I believe the OP to be inexperienced.

--

Terry Kreft
"DFS" <nospam@dfs_.comwrote in message
news:X6****************@bignews1.bellsouth.net...
Terry Kreft wrote:
You should not open tables.

This is bogus advice, I think.

You should open tables if you need to or if you want to. There's
certainly
no need to create a form and report for every table in your system, eg
just
to edit a small lookup table (or even a large transaction table).
Especially if you "know" your data.
You should use a form for data entry and a report for data review.

Why? Though a well-defined form can give you more control and safety,
it's
no panacea, and building good validation rules and proper data typing can
aid in entering data directly in tables.
Either way, you use a query as the recordsource as you can then sort
the data in any way you want.

Yes. Or you can filter and sort it pretty much any way you want if you
open
the table directly.

"Troy" <Tr**********@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
Public Sub test()

DoCmd.OpenTable ("OSM Table 1")

End Sub

Amazingly, I've gotten this far, now I am wondering how to sort the
database in ascending order according to field called [Meal Total]
and then select the first record. It's all got to be in VBA, can
anyone help?

Thanks


Jul 18 '06 #9
Tim Marshall <TI****@PurplePandaChasers.Moertheriumwrote in
news:e9**********@coranto.ucs.mun.ca:
But I vaguely recall at some point wasn't/isn't there some report
property one can turn on to accept the sorting done by a query?
I don't know. I just learned a long time ago that sorting the
recordsource was so often a waste of time that I just stopped
trying!

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Jul 18 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: anders thoresson | last post by:
Is it possible to resort the rows in a table like in a query where using ORDER BY, but have to new sort order stored in the table structure? -- anders thoresson -- MySQL General Mailing List...
4
by: Matt | last post by:
Hi all, We recently upsized two Microsoft Access Databases to SQL. We're using an ADP (2002) as the front end. All the conversion issues have been resolved, except for one: Whenever we...
0
by: isaphrael | last post by:
-using Access 2000 I have a table, CC that will be having records added to it, and on a form I will have a button to step through all of the records within CC. However, CC is sorted by 3 columns,...
14
by: amywolfie | last post by:
Hi All: I know this is simple, but I just can't seem to get there: I need to sort a table by a text field (txtDescription), then assign sequential numbers to the field SEQUENCE in table. ...
1
by: deko | last post by:
I need to import dates from a linked table then export them out as text to an Excel spreadsheet. The problem is the dates need to be in ascending order when I dump them out to Excel - and there's...
26
by: Daron | last post by:
How do I sort a table, from a form. I can't use SQL! WE have an Access application that is created by an outside vendor. The one form states: "Please make sure all records in table are sorted by...
2
by: Yanir | last post by:
H I have to display a sortable list of columns(a table or so) - by click on the title of a column, the column would be the criteria to sort by I know datagrid is very conveniant, but I want to save...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.