On 21 Apr 2004 21:37:29 GMT, Rich P <rpng123@aol.com> wrote:
[color=blue]
>Add a temp column to your query grid. This column will be populated
>with only a string of 10 numeric chars. The way you will populate this
>column is by writing a function as follows which will take values from
>your actual column in question. The function will parse the values for
>each row, and if there is a string containing 10 consecutive digits that
>value will be added to the temp column otherwise the function returns
>"".
>
>In the field name add this:
>
>temp:getNum(yourActualfieldnamehere)
>
>Under the criteria for temp add:
>
><> ""
>
>This will yield a resultset where only rows that contain values from
>your actual column that are 10 consecutive numeric chars.
>
>Here is a function that does this:
>
>'******************************************
>Function getNum(x As Variant) As Variant
>Dim i As Integer, j As Integer, k As Integer, y As Variant
>For i = 1 To Len(x)
> y = Mid(x, i, 1)
> If j = 0 And IsNumeric(y) Then j = i 'beginning of number
> If j > 0 And Not IsNumeric(y) Then
> k = i - 1
> Exit For
> End If
> If j > 0 And i - j + 1 = 10 Then
> k = i
> Exit For
> End If
>Next
>If k - j - 9 = 0 Then getNum = Mid(x, j, 10)
>End Function
>'************************************************ ****
>
>It isn't pretty, but it is functional, and Free! This function will
>return values like these
>
>1231231234, 1234567890
>
>from xx1231231234 or 1231231234xxx or aaa1234567890kkk
>
>and will not return values like these
>
>123123123 (only 9 digits)
>or 1 231231234 (a space breaks the continuity)
>or xxx12312312x3 (not 10 consecutive digits)
>
>based on your specifications. You can place this function in a standard
>code module (not a form code module) so that the query can access it.
>
>Rich
>
>*** Sent via Developersdex
http://www.developersdex.com ***
>Don't just participate in USENET...get rewarded for it![/color]
That works spot on. Well almost.
There are a number of records that have Null data, and these throw up a fault that stops the program
running, and opens the code editor, which give the user palpitations.
That code is a bit complicated so if anyone knows the answer I'd be grateful.
Thanks to all that have helped.
Smiley Bob