Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

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

ResolvedVersion 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:

How To Display An '&' In A Label In A Form

To have your label display a sentence with an &(ampersand) in it, like Fox & Hound simply type it as:

Fox && Hound

View all Access hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.08 secs.