Access 2007 - Form drop down list row source filter

I may be way off on this but I'm trying to "filter" a drop down list control in my form.  I can use the following as the row source to get all the values from the table....

SELECT [ICNTable].[ICNNumber] FROM ICNTable ORDER BY [ICNNumber];

But the ICN # is a combination of the CRN # (first 7 charactions) plus 4 characters.  I've used this type of syntax before in writing queries in VB but I was hoping to use it as the row source for the drop down box.  I don't get a syntax error when I run the form but it still shows me all the records when I want just the ones that have a specific value in the first 7 places.  Is this possible?

SELECT [ICNTable].[ICNNumber] FROM ICNTable WHERE "left(ICNNumber,7) = " & chr$(34) & CRNNumber & chr$(34) ORDER BY [ICNNumber];

Thanks!
Helen
greenprgAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

answer_dudeCommented:
Where is CRNNumber coming from?  If it's a field on the table, then just do:

SELECT DISTINCT ICNTable.CRNNumber
FROM ICNTable;
answer_dudeCommented:
If you want ICNNumber returned, though -- and if CRNNumber is on the table... and if ICNNumber is always CRNNumber + 4 digits... then you'll still be selecting all ICNNumbers anyway.
answer_dudeCommented:
Based on your SQL example, this would be the closest to what you want (but again, assuming CRNNumber is always a subset of ISNNumber then you're probably not going to get your desired result).
SELECT DISTINCT ICNTable.ICNNumber, Left([ICNNumber],7) AS ICNLeft
FROM ICNTable
WHERE (((Left([ICNNumber],7))=ICNTable.CRNNumber));

Open in new window

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

answer_dudeCommented:
Sorry... this one:
SELECT DISTINCT ICNTable.ICNNumber
FROM ICNTable
WHERE (((Left([ICNNumber],7))=[ICNTable].[CRNNumber]))
ORDER BY ICNTable.ICNNumber;

Open in new window

greenprgAuthor Commented:
Sorry for the delay.  I thought I posted this reply already but then I had a virus problem I had to deal with.  Fun....Fun.

So anyway, I tried the following

SELECT [ICNTable].[ICNNumber] FROM ICNTable WHERE (Left(ICNNumber,7)=CRNNumber) ORDER BY ICNNumber;

which does not give any syntax error but it still lists ALL ICN Numbers.  I only want the ones that have the same 7 starting digits as the CRNNumber displaying in the form.  I tried me.CRNNumber but then I get Enter Parameter Value when I click on the drop down list control.
answer_dudeCommented:
What is the name of the field on the form that contains the CRN Number?
answer_dudeCommented:
If I understand you, you have a form that has a field that shows a particular CRN Number?  

In that case you want to change your query parameter to reference the field on the form.  See below
SELECT DISTINCT ICNTable.ICNNumber
FROM ICNTable
WHERE (((Left([ICNNumber],7))=[Forms]![MyForm]![txtCRNNumber]))
ORDER BY ICNTable.ICNNumber;

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
greenprgAuthor Commented:
Perfect!  It works great!

Thanks!
Helen
greenprgAuthor Commented:
Works perfectly.  Very cool!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.