Access 2007 Form - Combo Box rowsource error
Posted on 2010-09-14
My form has a combo box which gets set with the following in the rowsource property
SELECT [ICNTable].[ICNNumber] FROM ICNTable WHERE (Left(ICNNumber,8)=CRNNumber) ORDER BY ICNNumber;
It works fine but now the CRNNumber is changing to a variable length. So in the load event of the form I put in the following code
If Len(CRNNumber) <> 8 Then
targetLen = Len(CRNNumber)
ICNNum.RowSource = "SELECT ICNTable.ICNNumber FROM ICNTable WHERE " & _
"(Left (ICNNumber, 'targetLen') = CRNNumber) ORDER BY ICNNumber;"
and now I'm getting the following error message.
This expression is typed incorrectly, or it is too complex to be evaluated. For example, a numberic expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables.
I'm not sure where to go from here.