Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Re: Constraining Fields


Message #1 by "Ben Pearce" <benp@w...> on Thu, 8 Feb 2001 15:58:22
> How can I populate a subsequent field in a table depending on what

> was entered in the previous field?

>

> Mitch



Hi Mitch,



I can illustrate a way of doing this with an example:



Say you have a table into which you want to put addresses, tblAddresses, and like you say, want to limit cities according to the
region chosen.



1) Create a table of regions, tblRegions against a unique ID:



RegionID Region

1 West Midlands

2 Hampshire...



2) Create a table of cities, tblCities showing their relationship with a region:



CityID City RegionID

1 Birmingham 1

2 Coventry 1

3 Southampton 2...



3) Create a form, frmAddresses, based on tblAddresses. Create a combo box with the following properties:



Name = cboRegions

Control Source = 'Region' field in tblAddresses

Row Source = tblRegions

Bound Column = 1



(this will create a drop down list showing regions, and when one is selected, the RegionID will be recorded in the region field in
tblAddresses).



4) Create a query, qryLimitCities, based on tblCities. Group By CityID, and WHERE RegionID = [Forms]![frmAddresses]![cboRegions]
(type this into the criteria box).



5) Create another combo box, with these properties:



Control Source = 'City' field in tblAddresses

Row Source = qryLimitCities

BoundColumn = 1





Now, when you select a region from the list on the form, only the cities that

belong to that region will be available to select in the 2nd list.



Hope this helps,



Ben.

 


  Return to Index