exprexssion

Ziggy1

Registered User.
Local time
Today, 09:39
Joined
Feb 6, 2002
Messages
462
How can I evaluate my field to pull out the first number from the right, if some records end in a letter and some do not.


C1005B -> Extract 5
C4152 -> Extract 2

I'm familiar with the left/right/mid functions, I know it will need an "If then" with something like isnumber istext but I jus have to put it together.

I'll keep plugging away but hopefully someone can help me get it done quicker


Thanks

Ziggy
 
Hi

You can use the isnumeric function as follows

Create a module

enter

Public function GetFirstVal(StrFieldData as string ) as integer

if isnumeric(Right(StrFieldData,1)) = True then

GetFirstVal = Right(StrFieldData,1)

else

GetFirstVal = mid(StrFieldData, len(StrFieldData)-1,1)

end if

end function

Make sure you do not use the name of the function as the name of the module


In the query builder you can now use this function.

NewData: GetFirstVal(Enter the name of your field here)





Hope that helps

Chris
 
Last edited:
Excellent!! Thanks alot that worked great!


Ziggy
 

Users who are viewing this thread

Back
Top Bottom