Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Developer Network    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
O or D Fix for Last Name
James Nardone 
      
17 hours ago
I've tried to correct an issue for some import of last names from an Excel sheet that has names like O'Brien or D'Angelo listed as "O Brien" or "D Angelo". Unfortunately, that's how the list comes to me. I tried to use an update query but sometimes it gives the wrong name such as O'ien or O'onnor where it deleted the B or C in the last name. Here's the update query.

UPDATE dbo_Contacts
SET
    dbo_Contacts.[Last Name] = Left([Last Name], 1) & "'" & StrConv (Mid ([Last Name], 4), 3)
WHERE
    (
        ((Mid ([last name], 2, 1)) = " ")
        AND ((Left([Last Name], 1)) = "o")
    )
    OR (
        ((Mid ([last name], 2, 1)) = " ")
        AND ((Left([Last Name], 1)) = "d")
    );

And yes, this is before I rebuilt my database with better field names. :)

Any help would be appreciated.
Kevin Robertson  @Reply  
          
16 hours ago
Try this:

I did this with a button on a form:

Private Sub btnFixLastName_Click()

    CurrentDb.Execute "UPDATE ContactT " & _
                        "SET NewLastName=Replace(LastName, "" "", ""'"") " & _
                        "WHERE InStr(LastName, "" "") = 2"
    
    Me.Requery
    
End Sub


Then I switched to your syntax above:

UPDATE dbo_Contacts
SET
    dbo_Contacts.[Last Name] = Replace([Last Name], " ", "'")
WHERE
    InStr(LastName, " ") = 2;
James Nardone OP  @Reply  
      
11 hours ago
Thanks! That's just what I needed.
Add a Reply Upload an Image
Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/11/2026 1:46:32 AM. PLT: 0s