Combo/Select Distinct

  • Thread starter Thread starter Cyndi
  • Start date Start date
C

Cyndi

Ok I am an accountant(knows a little about computers) so assume I am a
complete dunce -

I have a database multiple tables - one table has the customer ID and
the year I am looking for - but the customer name is actually in
another table

I want to do 2 combo boxes

the first would select customer name _________________

and then the second would pop up the year(s) we have in the table
______________

I have printed(off this) multiple articles about combo boxes and
select distint row but none seem to fit my problem where I only have
the ID in the main table not the whole name.

Thanks in advance for any help
 
Your first combo box should be based on a query of your customer that
returns the ID and name. Display the name in the combo box, but have the ID
field as the bound column. In the AfterUpdate event of that combo box, put
code that builds a simple SQL string to be the source of the second combo
box.

strSQL = "SELECT CustomerYear FROM CustomerYearTable " & _
"WHERE CustomerId = " & Me.cboCustomer & " " & _
"ORDER BY CustomerYear"

With Me.cboCustomerYear
.RowSourceType = "Table/Query"
.RowSource = strSQL
End With

(Obviously since I don't know the details of your application, I couldn't
use appropriate names in the example above)
 
Cyndi,

Essentially what you have to do is reset the 2nd combo's RowSource when you
select a value from the first one. In your case the value you'll pass is the
CustomerID. See if the following page helps:

http://www.pacificdb.com.au/MVP/Code/ComboRS.htm

Graham R Seach
Microsoft Access MCP, MVP
Sydney, Australia
 

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

Back
Top