Using a sub-form to navigate the main form

  • Thread starter Thread starter Alex
  • Start date Start date
A

Alex

There's probably a very simple way to accomplish what I am trying to do, but I
can't get it to work. I have a table (Customers) with two fields: CustomerID
and CustomerName. CustomerID is the Primary Key. I also have a Query
(CustomersByName) that returns all the rows in the Customers table sorted by
CustomerName. What I would like to do and can't get to work properly is having
a form (in columnar layout) for editing the CustomerName, and also a sub-form
(in tabular layout) that uses the CustomersByName query as a record source, and
that is used for navigating the Customers table. In other words, what I would
like to happen is that the user selects a record for editing by clicking on a
row in the subform, but the actual editing is done in the main form. I hope
that my explanation makes sense, and that somebody can show me how to
accomplish this. I'm using Access 2002.

Thanks.
 
That's kinda backwards to how subforms are designed to be used. How about
using a list box instead of a subform?

The list box is unbound.
Its RowSource is the query you were using for your subform.
Its AfterUpdate event finds the record in the main form.

Alternatively, if you want a code-free design, you can use an unbound main
form that contains just the list box and a subform. The subform contains the
form-view form (shows one record). The LinkMasterFields property of the
subform control is set to the name of the listbox, and the LinkChildFields
to the matching key field in the subform.
 
Allen Browne said:
That's kinda backwards to how subforms are designed to be used.

I'm not surprised by that comment. I have a lot of experience using Access as
a backend to an application, but none as a front end.
How about
using a list box instead of a subform?

That's a good alternative. I thought that using a subform would give me more
control over the appearance of the list, but in all honesty a list box is good
enough.

Thank you.
 
Back
Top