Heenan, Lambert
Lambert.Heenan at AIG.com
Thu Nov 9 13:22:13 CST 2006
Well, while the help file is not explicit on this, the results you are seeing do make sense. Val() is supposed to extract a numeric value from the left end of a string, skipping over any spaces and the recognizing "&O" and "&H" to indicate Octal and Hex numbers. So Val("1abcde") will return 1, but Val("abcd") will return 0 (zero). This is because Val() is declare as returning a double, so the "value" of an all alpha string is treated as zero. And so Len(Val("abcd")) will be 1 not zero. If your intent was to find out if a string *begins* with a numeric value then you could try... If IsNumeric(Left(Trim(strValue),1)) Then ' Got a digit Else ' Does not start with a digit End If Lambert -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Susan Harkins Sent: Thursday, November 09, 2006 1:46 PM To: 'Access Developers discussion and problem solving' Subject: [AccessD] Interesting behavior with Val() I've read Help looking for an explanation for what I'm about to say, but haven't found one. The following expression returns 1 if value has no numeric digits: Len(Val(value)) I expected the expression to return 0. You can test this on the Employees table in Northwind -- there are two records where the Address value is alpha text, with no numeric digits at the beginning of the value. The above expression, against those two values, returns 1. What am I missing? Susan H. -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com