drop down box question

S

steve goodrich

i have a staff database set up with part of the form for vehicle details,
reg, make, model, colour. at the moment i type the details in manually.

i would like to use drop down boxes for the make and model fields. i know
how to do this by creating tables for make and model and then using the
wizard link them to the form.

how do i create the drop down boxes so that when i enter "ford" in the make
box for example, and then click on the model drop down box, only ford makes
are displayed the same way that autotrader works
thanks for any help
steve

using access 97
windows nt
 
F

fredg

i have a staff database set up with part of the form for vehicle details,
reg, make, model, colour. at the moment i type the details in manually.

i would like to use drop down boxes for the make and model fields. i know
how to do this by creating tables for make and model and then using the
wizard link them to the form.

how do i create the drop down boxes so that when i enter "ford" in the make
box for example, and then click on the model drop down box, only ford makes
are displayed the same way that autotrader works
thanks for any help
steve

using access 97
windows nt

Leave the cboModel RowSource property blank.
Code the cboMake combo box AfterUpdate event:

cboModel.Rowsource = "Select YourTableName.Model from YourTableName
Where YourTableName.Make = '" & Me!cboMake & "' Order by Model;"

Substitute the correct table and field names as required.
The above assumes the cboMake bound column is text, not number.
 
J

John Vinson

how do i create the drop down boxes so that when i enter "ford" in the make
box for example, and then click on the model drop down box, only ford makes
are displayed the same way that autotrader works

Well, I don't know anything about autotrader, but this functionality
is pretty easy. Base the Model combo box (the proper name for a "drop
down") on a Query referencing the Make box: e.g.

SELECT Model FROM tblModels
WHERE Make = [Forms]![YourFormName]![cboMake]
ORDER BY Model;

You'll also need one line of VBA code. In the AfterUpdate event of the
Make combo box, requery the Model combo: click the ... icon, invoke
the Code Builder, and put

Private Sub cboMake_AfterUpdate()
Me!cboModel.Requery
End Sub

John W. Vinson[MVP]
 

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