How to removing non Alpha-numeric characters

bleeet

Board Regular
Joined
May 11, 2009
Messages
190
Hi guys

I am new to access and I have made a data base but one of the columns has some non Alpha-numeric characters in each row that I want to remove. The fastest way to do this is to use VBA I guess. Does anyone happen to know how I can do this?


thanks
 

Some videos you may like

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
54,496
Office Version
  1. 365
Platform
  1. Windows
I was able to adapt the VBA User Defined Function here: Access World Forums - View Single Post - How to get rid of non - alpha-numeric characters? to do that. Here is the code:
Code:
Public Function AlphaNumOnly(inputString As Variant) As String


    Dim i As Integer
    Dim myString As String


    If Len(inputString) > 0 Then
        For i = 1 To Len(inputString)
            If Mid(inputString, i, 1) Like "[A-Z,0-9]" Then
                myString = myString & Mid(inputString, i, 1)
            End If
        Next i
    End If


     AlphaNumOnly = myString


End Function
So, if you place this code in a Standard VBA Module in your database, you will be able to use this like any other Access function in a Query calculated field, VBA, etc., i.e.

MyNewString: AlphaNumOnly([TextField])
 

Watch MrExcel Video

Forum statistics

Threads
1,109,380
Messages
5,528,366
Members
409,817
Latest member
JiNXX9500

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top