combo box only
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

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

replyReply Tue 9 Sep 2008, 12:00Delegate Clare said...

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

For upcoming training course dates see: Pricing & availability

replyReply Fri 26 Sep 2008, 11:53Trainer Laura said...

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

 

Please browse our web site to find out more about
access course london and other Microsoft training courses.

Access tip:

Modal forms

If you have created a form / switchboard and dont want people to get away from using the switchboard, you can change the form properites for Modal to On.

View all Access hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard