Sub Form Problem

E

Edgar Thoemmes

I have a Form with a sub form. The sub form holds details of contracts held
by a supplier. Each supplier could have many contracts so I have put a list
box onto the form which displays a list of all contracts for the supplier
selected on the main form.

There is also a frame which the user could select (expired, active or all)
contracts. The after update event then filters the rowsource of the list box.

The user can then select the contract they would like to view from the
listbox and it will be displayed on the form with the following code:

Sub lstContractDates_AfterUpdate()
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[ContractID] = " & Me![lstContractDates]
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub

This all works fine but my problem is: The frame control default value is
Active Contracts, so if a supplier only has a an expired contract it will not
show up in the list box but all the details of the contract will be displayed
in the form.

What I want is if there are no active contracts for the form fields to be
blank and then if the user wants to select the expired contracts from the
list box it will then display the contract details in the form.

I have experimented with setting the record source of the form and the
control source of the objects on the form via VBA when either the user
selects an option from the list but either the code takes ages to execute or
the method i am using is wrong.

Could any give me any suggestions on how I may over come this problem?

Thanks
 

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