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 Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Call function update text box
Simon R 

11 years ago
Hi have made a number of bit of code like:

    LastName = StrConv(LastName, vbProperCase)

        'Now, take care of StrConv() shortcomings

        'If first two letters are "Mc", cap third letter.
    If Left(LastName, 2) = "Mc" Then
        LastName = Left(LastName, 2) & _
            UCase(Mid(LastName, 3, 1)) & Mid(LastName, 4)
            
        'If first three letters are "Mac", cap fourth letter.
    ElseIf Left(LastName, 3) = "Mac" Then
        LastName = Left(LastName, 3) & _
            UCase(Mid(LastName, 4, 1)) & Mid(LastName, 5)
    End If

Is their a way to make this a sub/function that is called on rather then putting it in every field box that need the bit of code. on each of my forms

I had a go and just cant get the text to update i seem to be missing something

Private Sub LastName_AfterUpdate()

    PCase (LastName)

End Sub

Public Function PCase(FeildName As String) As String
    Dim FixedText As String

    FixedText = StrConv(FixedText, vbProperCase)

        'Now, take care of StrConv() shortcomings

        'If first two letters are "Mc", cap third letter.
    If Left(FixedText, 2) = "Mc" Then
        FixedText = Left(FixedText, 2) & _
            UCase(Mid(FixedText, 3, 1)) & Mid(FixedText, 4)
            
        'If first three letters are "Mac", cap fourth letter.
    ElseIf Left(FixedText, 3) = "Mac" Then
        FixedText = Left(FixedText, 3) & _
            UCase(Mid(FixedText, 4, 1)) & Mid(FixedText, 5)
    End If

MsgBox FixedText 'this is the text need in Text field box

FeildName = FixedText

End Function



Reply from Alex Hedley:

FixedText is blank.

You pass in FieldName as a parameter and then don't use it. That's the value you want to pass into your subsequent conversion functions.

Also why not use that in your Query that is then used in your Forms/Reports?

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

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/15/2026 2:00:21 AM. PLT: 0s