restricting records in a combo field in a datasheet

  • Thread starter Thread starter Shumboom
  • Start date Start date
S

Shumboom

hi

I have a datasheet which is a subform. I have fields Client,Contacts
and VisitDate in the datasheet. What I want is to be able to update my
Contacts field to only show the contacts that are in the Client.

I have an afterupdate on my Client field to only show those Contacts
which works for that record only. However when I choose different
records it keeps showing only the contacts for the last Client I
updated.

Is is possible to only show those Contacts that relate to the selected
Client in a datasheet.

thanks

Shumit
 
Does the main Form use the tblClient as the DataSource and the Subform use
the tblContact as the DataSource?

Are the Tables tblClient and tblContact related by a One-to-Many
relationship, i.e. there exists a ForeignKey in tblContact referring to
tblClient?

If the answers are Yes to all of the above, you can simply set the
LinkMasterFields / LinkChildFields of the SubformControl to the PrimaryKey /
ForeignKey pair and Access will filter the Subform automatically (no code is
needed)

Check Access Help on the Subform.
 
Van said:
Does the main Form use the tblClient as the DataSource and the Subform use
the tblContact as the DataSource?

Are the Tables tblClient and tblContact related by a One-to-Many
relationship, i.e. there exists a ForeignKey in tblContact referring to
tblClient?

The answers are No & Yes. The main form is actually Employees, the sub
form are visits to the clients that they need to make.
 
If I understand your description correctly, you want a dynamic ComboBox
Contacts (on the SubForm) which is filtered according to the current
ClientID which is a Field in the Subform RecordSource???

In that canse, you need to use the Current Event of the Subform to re-query
the ComboBox whose RowSource is a parametrised Query / SQL with ClientID as
the Parameter.
 
Back
Top