Re: remove alpha content in text field
From: vw (anonymous_at_discussions.microsoft.com)
Date: 07/22/04
- Next message: Jamie Collins: "Re: SQL problem - Jamie"
- Previous message: MichaelK: "Re: Not Updatable Query problem"
- In reply to: fredg: "Re: remove alpha content in text field"
- Next in thread: Graham R Seach: "Re: remove alpha content in text field"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 21 Jul 2004 23:03:20 -0700
Thks for this. Alpha is at beginning of field so what
you've sent should suffice.
Regds
>-----Original Message-----
>On Wed, 21 Jul 2004 18:00:50 -0700, vw wrote:
>
>> 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.
>.
>
- Next message: Jamie Collins: "Re: SQL problem - Jamie"
- Previous message: MichaelK: "Re: Not Updatable Query problem"
- In reply to: fredg: "Re: remove alpha content in text field"
- Next in thread: Graham R Seach: "Re: remove alpha content in text field"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|