Results 1 to 3 of 3
  1. #1
    nikhil007 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    3

    Removal of all special charcaters from Access database fields automaticallyVBA code

    It is one of the challenging problems that we are facing. We have a access table containing customer details and records to the tune of about 16-17 lacs.
    Problem is that details of customer in access contains special characters.

    Below attached code does not give me the option to run it in access, as also in excel,since it is run using a userdefined custom defined function in excel sheet on a single cell. It is not working as a macro.

    What i want is that below code with modifications should run in access as a VBA code on all selected fields like customer name and father name in database automatically and shall remove all special charcaters in database and generate query containing records of all those with special characters.

    Any help on this is highly appreciated. Any other info if required, kindly let me know.

    Rgds
    Nikhil
    ================================================== =========================================

    Function CleanSpecialChars( ByVal varField as Variant) As Variant

    Dim strSpecialChars As String
    Dim intLen as Integer
    Dim intCounter As Integer

    strSpecialChars = "<>{}[]*&^%#@!~^$" '<== //TODO: Add to this string all characters
    ' you want to remove (do not include comma(,))
    intLen = Len(strSpecialChars)

    if Not IsNull(varField) Then
    intCounter = 1
    While intCounter <= intLen
    ' remove special chars
    varField = Replace(varField, Mid(strSpecialChars, intCounter, 1), "")
    intCounter = intCounter + 1
    Wend
    End If
    CleanSpecialChars = varField


    End Function

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    If you want only alpha and numeric characters, you could work with the code at
    http://access.mvps.org/access/strings/str0002.htm

    You'll have to adjust to allow only a-z and A-Z and 0-9

    but I'd be cautious in trying to identify all the "special characters" and then remove them.

    Just a thought.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Query publish to word results in removal?
    By allstar45 in forum Queries
    Replies: 6
    Last Post: 03-13-2012, 06:24 AM
  2. Time Stamp Removal/deletion?
    By thorsonb in forum Access
    Replies: 3
    Last Post: 03-30-2010, 10:17 PM
  3. Hi. I need very, very special help for Ms Access!
    By accessnotknow in forum Access
    Replies: 0
    Last Post: 06-12-2009, 12:21 PM
  4. Link tables on "special" fields
    By Gargen in forum Access
    Replies: 0
    Last Post: 12-18-2008, 12:02 PM
  5. Replies: 3
    Last Post: 04-05-2006, 04:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums