I have a list of many part numbers of varying length and formats that I am trying to obtain the last two numerics within that part number. the part number could be like cr2344-32-05 or it could be 3239ew06wx. I need to return only the 05 or 06. I have tried to test this in a text box using some code I found on microsoft.
Then I used the code:
When the AfterUpdate is activated, it gives me an error saying Compile Error: Expected variable or proceedure, not module.
Im not really sure how to fix this problem. Thanks in advance!
Code:
Function RemoveAlphas (ByVal AlphaNum as Variant) Dim Clean As String Dim Pos, A_Char$ Pos = 1 If IsNull(AlphaNum) Then Exit Function For Pos = 1 To Len(AlphaNum) A_Char$ = Mid(AlphaNum, Pos, 1) If A_Char$ >= "0" And A_Char$ <= "9" Then Clean$ = Clean$ + A_Char$ End If Next Pos RemoveAlphas = Clean$ End Function
Code:
Private Sub txtTest_AfterUpdate() Me![txtTest] = RemoveAlphas(Me![txtTest]) End Sub
Im not really sure how to fix this problem. Thanks in advance!
Comment