Get data using Combo Boxes

P

Praveen Manne

Hi,

I have 2 tables;
1. Demo: ID, LastName, FirstName (fields in the table Demo) ID is the
Primary key.
2. Orders: Last Name, First Name, NoOfOrders .......

I chose Last Name and First Name as the primary fields because I want the
users of this application, be able to select the Names from a combo box
instead of selecting their ID's.

Here I have 2 problems,

1. when I select Last Name in the first combo, it should filter the values
in the First Name combo. ( I tried so many ways to do this, but I failed all
the times)
2. And when the First Name Combo got selected, I want the SSN textbox field
which is empty, should populate the correct SSN value from the first table.

Please Help

Thanks
Praveen Manne
 
D

Dale Fye

Praveen,

1. Set the rowsource for the FirstName combo box to a query which selects
the distinct firstname from DEMO where the LastName is equal to the value of
the first combo box. The SQL will look something like:

SELECT DISTINCT FirstName FROM DEMO WHERE LastName = me.cbo_LastName

2. In the AfterUpdate event of the LastName combo box, requery the
FirstName combo box.

Private Sub cbo_LastName_AfterUpdate()

me.cbo_FirstName.requery

End Sub

HTH
Dale
 

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