Clare has attended:
Access Advanced course
Access VBA course
Combo box - only allowing it to show specific data from another
Hi
I have a combo box which is linked to another table in my database.
However the specific field in the table that the combo box is linked to can sometimes include duplicate values.
I only want my combo box to show each different value once.
I also want it to only show data from the table which has been entered from a specific date till now.
I think I have an idea on this but don't know where to start..
Please help!
Kind Regards
Clare
RE: Combo box - only allowing it to show specific data from anot
Hi Clare
Thanks for the question.
For both parts the query behind the combo box needs changing. To get the unique values you need to change the query properties. Either right click in the query design window and get the query property dialog window up, then change "Unique Values" to Yes.
OR If you are happy to change the SQL you need to add the word DISTINCT after the word SELECT in your statement.
To do the second point is slightly harder. Is there a date of entering recorded in your database? Access does not do automatic auditing.
If there is then you need to add a criteria to that datefield.
If you are wanting to change the combobox source data from within vba then the line you are looking for is something similar to:
Me.cmbNames.RowSource = "Select Distinct [Product Names] from [tbl Products] where [CreateDate] >= #" & me.InputDate & "#"
I hope that helps
Laura