Show records as tabs or in a list

C

coreym123

I have two tablse, Trip and Stop. Each Trip has multiple stops. On a
form, the Trip record shows, and the Stops for that trip display in a
subform.

Each trip has 3-5 stops. Is it possible to show each stop as a tab on
the subform that can be switched to? If not, is there another
solution, like displaying the stops in a list box and bringing up that
record when that stop is selected? I'm trying to find a godo way to
show all the stops at once and be able to choose the one you want to
edit, while not having to open up another form.

Advice would be much appreciated.

Thanks,
Corey
 
K

Ken Sheridan

Corey:

The list box approach is probably the best here. Add a list box to the main
Trip form, calling it lstStops say. Set its RowSource so it shows the stops
fro the current trip, e.g.

SELECT StopID, Stop FROM Stop WHERE TripID = Forms!frmTrip!TripID;

In this example TripID is the primary key of the Trip table and the
corresponding foreign key in the Stop table. StopID is the primary key of
the Stop table, and should be the bound column of the list box. When
returning two columns like this you can hide the StopID column and show just
the Stop column by setting the control's ColumnWidths property to something
like 0cm;8cm (Access will automatically convert it to inches if you are using
imperial units rather than metric). The ColumnCount property should be set
to 2.

In the main form's Current event procedure requery the list box with:

Me.lstStops.Requery

And in the AfterUpdate event procedure of the list box requery the subform
with:

Me.sfrStops.Requery

where sfrStops is the name of the subform control, i.e. the control in the
main form which houses the subform.

Set the subform's default view to Single Form and design it however you want
it laid out for editing a single record. Set the LinkMasterFields property
of the subform control to the name of the list box on the parent form, i.e.
lstStops (you don't need to qualify it with the form name, just the name of
the control will do), and set its LinkChildFields property to StopID, i.e.
the name of the Stop table's primary key column.

When you select an item from the list box the subform should show the
selected Stop record ready for editing.

Ken Sheridan
Stafford, England
 
C

coreym123

Corey:

The list box approach is probably the best here.  Add a list box to the main
Trip form, calling it lstStops say.  Set its RowSource so it shows the stops
fro the current trip, e.g.

SELECT StopID, Stop FROM Stop WHERE TripID = Forms!frmTrip!TripID;

In this example TripID is the primary key of the Trip table and the
corresponding foreign key in the Stop table.  StopID is the primary key of
the Stop table, and should be the bound column of the list box.  When
returning two columns like this you can hide the StopID column and show just
the Stop column by setting the control's ColumnWidths property to something
like 0cm;8cm (Access will automatically convert it to inches if you are using
imperial units rather than metric).  The ColumnCount property should be set
to 2.

In the main form's Current event procedure requery the list box with:

Me.lstStops.Requery

And in the AfterUpdate event procedure of the list box requery the subform
with:

Me.sfrStops.Requery

where sfrStops is the name of the subform control, i.e. the control in the
main form which houses the subform.

Set the subform's default view to Single Form and design it however you want
it laid out for editing a single record.  Set the LinkMasterFields property
of the subform control to the name of the list box on the parent form, i.e..
lstStops (you don't need to qualify it with the form name, just the name of
the control will do), and set its LinkChildFields property to StopID, i.e.
the name of the Stop table's primary key column.

When you select an item from the list box the subform should show the
selected Stop record ready for editing.

Ken Sheridan
Stafford, England








- Show quoted text -

Works perfectly - thank you so much!
 

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