-----Original Message-----
Is there an existing command (ie an easy way) to remove
alpha entries in an existing alpha-numeric field. EG I
want to see results where original field entry is AB1234,
result field is 1234.
Any ideas?
If the number was always at the beginning of the field, i.e. 1234AB,
you could use in a query:
Resultfield:Val([FieldName])
But as long as the numbers can be anywhere within the field you'll
need to check each character.
If the numbers in the field are going to be all together (AB1234) as
in your sample data, and not mixed up within the field (ab4cv5k6) the
following will work for you.
You need to create a user defined function to cycle through the value
in each record until you find the first number character:
In a Module:
Function ValNumber(strString As String) As Integer
On Error GoTo Err_Handler
Dim intX As Integer
Dim intY As Integer
intY = Asc(strString)
Do While intY < 48 Or intY > 57
intX = intX + 1
If intX = Len(strString) Then Exit Do
intY = Asc(Mid(strString, intX, 1))
Loop
If intX = 0 Then intX = 1
ValNumber = Val(Mid(strString, intX))
Exit_ValNumber:
Exit Function
Err_Handler:
Resume Exit_ValNumber
End Function
===
You can call it from a query:
Result:ValNumber([FieldName])
As criteria in the query use:
Where [FieldName] is not null
If the numbers are mixed up within the field, i.e. ab4kl6fv9, the
method would be similar to the above, but you would have to cycle
through each character in the string and move the numbers to a
different string.
If that's the case, and you can't figure out how, post back and I'll
send the code along.
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
.