In a subform datasheet, how to order by a field?

G

Guest

I have a form & subform for data entry. The main form links to a parent table
that contains info about water samples and the subform links to its child
that contains info about many different substances that are analyzed in each
sample.

The subform is displayed in datasheet view. I would like the records that
are displayed in the form to stay in the order I enter them, so I can stop
data entry and then return without losing my place. But when I close the form
and reopen it, the subform records rearrange themselves--not in any order I
can figure out.

I tried setting the subform's "Order By" property to "ObservationID" (this
is the primary key of the analyses (child) table, and it's an Autonumber that
gets assigned when I create the record). That seems to have no effect.

I read about using a query to provide values for a subform, but that
wouldn't let me enter data, would it?

Thanks for your help.
 
G

Guest

Why can't a query be a source for your subform, if you link the subform to
the parent and the proper ID-field is presented in the query than you can
enter data in the subform as well..

Maurice
 
G

George Nicholson

Setting OrderBy by itself is only half the job. The OrderByOn property also
needs to get turned on, either by clicking the Sort button on the toolbar or
via code.

Alternatively, create a query that sorts the table by the desired field and
then base the subform on that query.

This is one reason that forms are usually based on queries, not tables
directly: queries give you control over the sort order.

HTH,
 
G

Guest

Hey, thanks much. I thought you couldn't change field values in a table by
simply editing the corresponding field in a query based on that table. I see
you can.
 
G

George Nicholson

I thought you couldn't change field values in a table by
simply editing the corresponding field in a query based on that table. I
see
you can.

It depends upon the Select query. For instance:
- If a Select query is based on multiple tables, it *might* not be editable.
Depends on the complexity of the joins.
- Select Queries with aggregate functions (Sum, Count, etc.) become
uneditable (a single query record potentially represents multiple data
records, so which records would you expect to get updated, even if it was
allowed?).
- Database functions (Dlookup, etc.) also turn a Select query uneditable. i
believe.

I'm sure this is not an exhaustive list. But simple single-table queries
(the kind you would use as the basis for a form) are almost always editable.

HTH,
 
G

Guest

Well put George....

Maurice

George Nicholson said:
Setting OrderBy by itself is only half the job. The OrderByOn property also
needs to get turned on, either by clicking the Sort button on the toolbar or
via code.

Alternatively, create a query that sorts the table by the desired field and
then base the subform on that query.

This is one reason that forms are usually based on queries, not tables
directly: queries give you control over the sort order.

HTH,
 

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