Limiting a drop down list to a value in another field

J

Joanne

Hello,
I have an Access database which lists certain software. There are two
fields; the software company, i.e. Microsoft, and then the name of the
software itself,i.e. Access. I want the name of the software to be limited
by the company name, so the second drop down would not list, say, Adobe
Acrobat. Is there a way to do this?
Many thanks in advance.
 
M

Marshall Barton

Joanne said:
I have an Access database which lists certain software. There are two
fields; the software company, i.e. Microsoft, and then the name of the
software itself,i.e. Access. I want the name of the software to be limited
by the company name, so the second drop down would not list, say, Adobe
Acrobat.


Set the software combo box's RowSource to a query likeL

SELECT softwarename, softwarecompany
FROM softwaretable
WHERE softwarecompany = Forms!yourform.thecompanycombobox
ORDER BY softwarename

Rhab add a line of code to the company combobox's
AfterUpdate event procedure:

Me.thesoftwarecombobox.Requery

If you form can display more than one record, add the same
line to the form's Current event.
 
J

Jack Leach

In the AfterUpdate event of the first combo, try something like this...


If Not Isnull(Me.Combo1) Then
'set the rowsource of Combo2
Me.Combo2.Enabled = True
Me.Combo2.RowSource = _
"SELECT * FROM listtable WHERE IDField = """ & Me.Combo1 & """"
Else
'Disable Combo2
Me.Combo2.Enabled = False
End If

You'll have to fill in the control names and SQL accordingly, but this is
the standard method for filtering one combo box based on another.

hth

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 

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