INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Combo Boxes

Combo Box - dependant on another Combo Box by KenReay
Posted: 10 Oct 03

Combo box dependant on another combo box

It is quite common to have a combo box from which you can choose a list of options, which then causes a second combo box to offer a list of options which are dependant on the first combo box.

The example below illustrates this.

Assumptions

Assume we have two simple tables as below:

Tables

TblManufacturers
LngManufacturerId û Autonumber û PK
StrManufacturerName

TblModels
LngManufacturerId û Long ) PK
LngModelId û Autonumber )
StrModelName

Combo Boxes

We have two combo boxes (cboManufacturer and cboModel) the two combo boxes are on a form (Form2) so

CboManufacturer
RowSource: SELECT tblManufacturers.lngManufacturerId, tblManufacturers.strManufacturerName
FROM tblManufacturers
ORDER BY tblManufacturers.strManufacturerName;


ColumnCount: 2

ColumnWidths: 0;2.54cm

LimitToList: Yes

Events:

Private Sub cboManufacturer_AfterUpdate()
    cboModel.Requery
End Sub


CboModel
RowSource: SELECT tblModels.lngModelId, tblModels.strModelName, tblModels.lngManufacturerId
FROM tblModels
WHERE (((tblModels.lngManufacturerId)=[Forms]![Form2]![cboManufacturer]))
ORDER BY tblModels.strModelName;


ColumnCount: 3

ColumnWidths: 0;2.54;0

LimitToList: Yes

Events:
Private Sub cboModel_GotFocus()
    If Len(Trim(Nz(cboManufacturer, "") & "")) = 0 Then
        MsgBox "Please Specify Manufacturer first"
        cboManufacturer.SetFocus
    Else
        cboModel.Requery
    End If
End Sub


Back to Microsoft: Access Forms FAQ Index
Back to Microsoft: Access Forms Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close