I have a simple table that contains numeric values in a text column (TaskNo).
tblTasks
ID Auto Number
TaskYear Date
TaskNo ShortText (10)
other fields ....
I would like to sort the table by TaskNo numerically and found this on the net - Expr1:IIF([FIELD] IS NULL, 0, VAL([FIELD]))
So I wrote this in the SQL view of my query
SELECT tblTasks.[TaskYear], tblTasks.[TaskNo], IIF(tblTasks.[TaskNo] IS NULL, 0, VAL(tblTasks.[TaskNo])) AS NumericTaskNo FROM tblTasks
I've left off the ORDER BY clauses for now as it doesn't change my issue.
When I change to design view I see the Expr has been correctly formed in the field.
But when I change to Data Sheet view I get the error:
Compile error in query expression: 'IIF(tblTasks.[TaskNo] IS NULL, 0, VAL(tblTasks.[TaskNo])' <-- notice it always leaves off the last character
The 'VAL' is highlighted. This occurs also with other functions such as MID, LEFT, RIGHT, etc.
I checked my references and they are all good (none missing, VBA is there, MS Access 15 Object Lib is there) and I can use all these functions without issue from the Access VB editor.
Also I cannot enter any function directly into the expression field while in design mode as it immediately complains it doesn't known about that function.
What am I missing?