Results 1 to 2 of 2
  1. #1
    craig1988 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2014
    Posts
    82

    Validating for invalid characters and informing user of records

    Hi All

    I have googled, but to no avail.



    I have an import function that asks the user for a file to import. Once imported, the data is queried and appended to further tables. I have no control over the data to be imported. I need to recognise any records that contain " ' " and inform the user somehow.

    Any ideas?

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    after import, run a select query on this bad item...
    select * from table where [field] like "*'*"

    if you have >1 bad character, put them in a table, tInvalidChars.
    '
    ~
    ^


    make a form, with a list box on it, lstChars. (the form is unbound)
    the list box is connected to tBadChars,
    put a button on the form to run this code
    Code:
    Public Sub btnScan_Click()
    Dim qdf As QueryDef
    Dim sSql As String, sWhere as string
    const kQRY = "qsFindBadChars"    'name of the query to search in data table
    const Q  =""""
    dim i as integer
    dim vChr
    On Error GoTo skipit
    set qdf = currentdb.querydefs(kQRY)
    sSql = "Select * from table "
      'scan list box of badchars
    for i = 0 to lstChars.listcount - 1
            vChr = lstChars.dataitem(i)
            sWhere = sWhere & "(like " & Q & "*" & vChr & "*" & Q  & ") or "     
    next i
    sWhere = left(sWhere ,len(swhere)-3)        'remove the last OR
      'save the sql
    qdf.SQL = sSQL
    qdf.close
      
      'run the sql
    docmd.openquery qdf.name
    Set qdf = Nothing
    End Sub

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

Similar Threads

  1. Replies: 4
    Last Post: 02-17-2016, 01:53 PM
  2. Replies: 4
    Last Post: 01-12-2015, 12:16 PM
  3. Replies: 1
    Last Post: 10-31-2013, 09:01 AM
  4. Compile Error: Invalid user of property
    By jwill in forum Programming
    Replies: 16
    Last Post: 11-20-2012, 05:23 PM
  5. VBA Import Error on Invalid Characters
    By jhrBanker in forum Import/Export Data
    Replies: 2
    Last Post: 11-25-2009, 12:07 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