combo box only

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » Combo box - only allowing it to show specific data from another

Combo box - only allowing it to show specific data from another

resolvedResolved · High Priority · Version 2003

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

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Access tip:

Dsum

You can create percentage values based on individual products / items by using a Dsum function (used with a grouped query)

[Each value column] / Dsum[field:total for the column needed to be calculated],[tablename]

View all Access hints and tips


Server loaded in 0.07 secs.